# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
242621 | 2020-06-28T10:58:32 Z | SamAnd | 나머지들의 합 (NOI12_modsum) | C++17 | 394 ms | 1272 KB |
#include <bits/stdc++.h> using namespace std; #define m_p make_pair #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define fi first #define se second typedef long long ll; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); mt19937 rnf(2106); const int N = 1003, M = 102; int n; int l[N], r[N]; int dp[N * M]; int ndp[N * M]; void solv() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d%d", &l[i], &r[i]); dp[0] = 1; for (int i = 1; i <= n; ++i) { memset(ndp, 0, sizeof ndp); for (int j = 0; j < N * M; ++j) { if (!dp[j]) continue; ndp[j + l[i]] += dp[j]; ndp[j + r[i] + 1] -= dp[j]; } memcpy(dp, ndp, sizeof ndp); for (int j = 1; j < N * M; ++j) dp[j] += dp[j - 1]; } int ans = 0; for (int j = 0; j < N * M; ++j) { int u = (j * 1LL * j) % 5; u = (u * (u + 2)) % 5; ++u; ans += dp[j] * u; } printf("%d\n", ans); } int main() { #ifdef SOMETHING freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #endif // SOMETHING //ios_base::sync_with_stdio(false), cin.tie(0); solv(); return 0; } //while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 1152 KB | Output is correct |
2 | Correct | 6 ms | 1152 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 1152 KB | Output is correct |
2 | Correct | 13 ms | 1152 KB | Output is correct |
3 | Correct | 14 ms | 1152 KB | Output is correct |
4 | Correct | 13 ms | 1152 KB | Output is correct |
5 | Correct | 13 ms | 1152 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 1152 KB | Output is correct |
2 | Correct | 44 ms | 1152 KB | Output is correct |
3 | Correct | 45 ms | 1152 KB | Output is correct |
4 | Correct | 47 ms | 1152 KB | Output is correct |
5 | Correct | 46 ms | 1152 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 83 ms | 1152 KB | Output is correct |
2 | Correct | 83 ms | 1152 KB | Output is correct |
3 | Correct | 83 ms | 1272 KB | Output is correct |
4 | Correct | 84 ms | 1152 KB | Output is correct |
5 | Correct | 85 ms | 1272 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 394 ms | 1272 KB | Output is correct |
2 | Correct | 393 ms | 1248 KB | Output is correct |
3 | Correct | 391 ms | 1152 KB | Output is correct |
4 | Correct | 394 ms | 1272 KB | Output is correct |
5 | Correct | 393 ms | 1152 KB | Output is correct |