This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |