Submission #901602

#TimeUsernameProblemLanguageResultExecution timeMemory
901602dsyzModsum (NOI12_modsum)C++17
25 / 25
76 ms544 KiB
#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 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...