Submission #874129

#TimeUsernameProblemLanguageResultExecution timeMemory
874129KakarotModsum (NOI12_modsum)C++98
25 / 25
83 ms536 KiB
#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 &current_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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...