# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1059078 |
2024-08-14T16:51:53 Z |
vjudge1 |
Modsum (NOI12_modsum) |
C++14 |
|
1 ms |
4568 KB |
/*
Discord: powder7854
https://www.facebook.com/hai290605
https://codeforces.com/profile/Etohari
https://oj.vnoi.info/user/powder
*/
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
//@Etohari
using namespace std;
using namespace __gnu_pbds;
template < class T, class G > bool minimum(T& a, const G b) { return b < a ? a = b, 1 : 0; }
template < class T, class G > bool maximum(T& a, const G b) { return a < b ? a = b, 1 : 0; }
template < class T > using heap_min = priority_queue < T, vector < T >, greater < T > >;
template < class T > using heap_max = priority_queue < T, vector < T >, less < T > >;
template < class T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < class T > using ordered_multiset = tree < T, null_type, less_equal < T >, rb_tree_tag, tree_order_statistics_node_update >;
#define my_wife "Thu"
#define bit(mask,i) ((mask>>i)&1)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define uniquev(v) sort(all(v)), (v).resize(unique(all(v)) - (v).begin())
#define __lcm(a,b) ((int64_t)(a) / __gcd((a), (b)) * (b))
#define rand(l, r) uniform_int_distribution < int64_t > (l, r)(rng)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
constexpr int32_t MOD = 1e9 + 7;
constexpr int32_t MAXN = 1e6 + 10;
constexpr int32_t MAXM = 1e6 + 10;
constexpr int32_t INF32 = 0x3f3f3f3f;
constexpr int64_t INF64 = 0x3f3f3f3f3f3f3f3f;
constexpr int16_t DR[] = { };
constexpr int16_t DC[] = { };
int n, l[MAXN], r[MAXN], dp[MAXN][5];
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i ++) {
cin >> l[i] >> r[i];
}
dp[0][0] = 1;
for (int i = 1; i <= n; i ++) {
for (int mod = 0; mod < 5; mod ++) {
for (int x = l[i]; x <= r[i]; x ++) {
int new_mod = (mod + x) % 5;
dp[i][new_mod] += dp[i - 1][mod];
}
}
}
int ans = 0;
for (int mod = 0; mod < 5; mod ++) {
int new_mod = (mod * mod * mod * mod + 2 * mod * mod) % 5 + 1;
ans += dp[n][mod] * new_mod;
}
cout << ans;
return (0 ^ 0);
}
/* Cho tới khi nào ? */
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
0 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
4444 KB |
Output is correct |
4 |
Correct |
0 ms |
4444 KB |
Output is correct |
5 |
Correct |
0 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
0 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
0 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
4444 KB |
Output is correct |
4 |
Correct |
0 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4568 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |