Contest Duration: - (local time) (100 minutes) Back to Home

Submission #10318264

Source Code Expand

Copy
```#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
∧＿∧
∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
（ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
／　　　＼　 　  |　|
/　　 /￣￣￣￣/　　|
＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int K, Q, D[5010];
int DD[5010];
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> K >> Q;
rep(i, 0, K) cin >> D[i];
rep(_, 0, Q) {
int N, X, M; cin >> N >> X >> M;

rep(k, 0, K) {
DD[k] = D[k] % M;
if (DD[k] == 0) DD[k] = M;
}
X %= M;

ll tot = 0;
rep(k, 0, K) tot += DD[k];

ll start = X;
ll end = X;

N--;
end += 1LL * (N / K) * tot;
rep(i, 0, (N%K)) end += DD[i];

ll ng = end / M - start / M;
ll ans = N - ng;
printf("%lld\n", ans);
}
}

```

#### Submission Info

Submission Time 2020-02-24 09:14:50+0900 F - Modularness hamayanhamayan C++14 (GCC 5.4.1) 600 1873 Byte AC 107 ms 384 KB

#### Judge Result

Set Name All Sample
Score / Max Score 600 / 600 0 / 0
Status
 AC × 52
 AC × 2
Set Name Test Cases
All sample_01.txt, sample_02.txt, testcase_1.txt, testcase_10.txt, testcase_11.txt, testcase_12.txt, testcase_13.txt, testcase_14.txt, testcase_15.txt, testcase_16.txt, testcase_17.txt, testcase_18.txt, testcase_19.txt, testcase_2.txt, testcase_20.txt, testcase_21.txt, testcase_22.txt, testcase_23.txt, testcase_24.txt, testcase_25.txt, testcase_26.txt, testcase_27.txt, testcase_28.txt, testcase_29.txt, testcase_3.txt, testcase_30.txt, testcase_31.txt, testcase_32.txt, testcase_33.txt, testcase_34.txt, testcase_35.txt, testcase_36.txt, testcase_37.txt, testcase_38.txt, testcase_39.txt, testcase_4.txt, testcase_40.txt, testcase_41.txt, testcase_42.txt, testcase_43.txt, testcase_44.txt, testcase_45.txt, testcase_46.txt, testcase_47.txt, testcase_48.txt, testcase_49.txt, testcase_5.txt, testcase_50.txt, testcase_6.txt, testcase_7.txt, testcase_8.txt, testcase_9.txt
Sample sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
testcase_1.txt AC 12 ms 256 KB
testcase_10.txt AC 24 ms 256 KB
testcase_11.txt AC 16 ms 256 KB
testcase_12.txt AC 17 ms 256 KB
testcase_13.txt AC 34 ms 256 KB
testcase_14.txt AC 34 ms 256 KB
testcase_15.txt AC 8 ms 256 KB
testcase_16.txt AC 23 ms 256 KB
testcase_17.txt AC 9 ms 256 KB
testcase_18.txt AC 19 ms 256 KB
testcase_19.txt AC 12 ms 256 KB
testcase_2.txt AC 32 ms 256 KB
testcase_20.txt AC 6 ms 256 KB
testcase_21.txt AC 14 ms 256 KB
testcase_22.txt AC 53 ms 256 KB
testcase_23.txt AC 5 ms 256 KB
testcase_24.txt AC 26 ms 256 KB
testcase_25.txt AC 10 ms 256 KB
testcase_26.txt AC 9 ms 256 KB
testcase_27.txt AC 47 ms 384 KB
testcase_28.txt AC 41 ms 256 KB
testcase_29.txt AC 8 ms 256 KB
testcase_3.txt AC 22 ms 256 KB
testcase_30.txt AC 35 ms 384 KB
testcase_31.txt AC 11 ms 256 KB
testcase_32.txt AC 11 ms 256 KB
testcase_33.txt AC 18 ms 256 KB
testcase_34.txt AC 12 ms 256 KB
testcase_35.txt AC 42 ms 384 KB
testcase_36.txt AC 27 ms 256 KB
testcase_37.txt AC 58 ms 384 KB
testcase_38.txt AC 13 ms 256 KB
testcase_39.txt AC 7 ms 256 KB
testcase_4.txt AC 70 ms 256 KB
testcase_40.txt AC 48 ms 384 KB
testcase_41.txt AC 6 ms 256 KB
testcase_42.txt AC 6 ms 256 KB
testcase_43.txt AC 12 ms 256 KB
testcase_44.txt AC 16 ms 256 KB
testcase_45.txt AC 19 ms 256 KB
testcase_46.txt AC 68 ms 384 KB
testcase_47.txt AC 29 ms 384 KB
testcase_48.txt AC 34 ms 384 KB
testcase_49.txt AC 4 ms 256 KB
testcase_5.txt AC 3 ms 256 KB
testcase_50.txt AC 107 ms 384 KB
testcase_6.txt AC 31 ms 256 KB
testcase_7.txt AC 47 ms 256 KB
testcase_8.txt AC 37 ms 256 KB
testcase_9.txt AC 24 ms 256 KB