# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
901602 |
2024-01-09T16:35:38 Z |
dsyz |
Modsum (NOI12_modsum) |
C++17 |
|
76 ms |
544 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1005)
ll N, ans = 0;
pair<ll,ll> arr[MAXN];
void recurse(ll i,ll sum){
if(i == N - 1){
for(ll val = arr[i].first;val <= arr[i].second;val++){
ll total = sum + val;
ans += ((((ll)powl(total,4) + 2ll*(ll)powl(total,2)) % 5ll) + 1ll);
}
return;
}
for(ll val = arr[i].first;val <= arr[i].second;val++){
recurse(i + 1,sum + val);
}
}
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);
cin>>N;
for(ll i = 0;i < N;i++){
cin>>arr[i].first>>arr[i].second;
}
recurse(0,0);
cout<<ans<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
18 ms |
452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
14 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
8 ms |
476 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
27 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
64 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
76 ms |
544 KB |
Output is correct |