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>
#define int long long
#define vi vector<int>
#define vii vector<pair<int,int>>
#define len(a) (int)a.size()
using namespace std;
void setIO() {
cin.tie(0)->ios_base::sync_with_stdio(0);
}
int f(vi &a) {
int x = accumulate(a.begin(),a.end(),0LL);
return (x*x*x*x + 2*x*x) % 5 + 1;
}
void recursive_helper(int index, vi ¤t_values, vii &range, int &total_sum) {
if(index == len(current_values)) {
total_sum += f(current_values);
}
else {
for(int x = range[index].first;x <= range[index].second;++x) {
current_values[index] = x;
recursive_helper(index + 1,current_values,range,total_sum);
}
}
}
void solve() {
int n,ans = 0;
cin >> n;
vii range(n);
for(auto &x : range) cin >> x.first >> x.second;
vi current_values(n);
recursive_helper(0,current_values,range,ans);
cout << ans << '\n';
}
int32_t main() {
setIO();
solve();
return 0;
}
# | 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... |