Submission #408606

#TimeUsernameProblemLanguageResultExecution timeMemory
408606strawberry2005Modsum (NOI12_modsum)C++17
25 / 25
92 ms396 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define F first #define S second #define mp make_pair #define nl '\n' const int mod = 1e9+7; #define deb(x) cout<<#x<<": "<<x<<endl int iceil(int a, int b) { return (a + b - 1) / b; } int n,ans=0,temp_sum=0; vector<pair<int,int>> inp; int f(){ return((temp_sum*temp_sum*temp_sum*temp_sum+2*temp_sum*temp_sum)%5+1); } void recur(int i){ if(i==n){ ans+=f(); return; } for(int j=inp[i].F;j<=inp[i].S;j++){ temp_sum+=j; recur(i+1); temp_sum-=j; } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #ifdef strawberryshaker2005 freopen("input.txt", "r", stdin); #endif cin>>n; for(int i=0;i<n;i++){ int a,b; cin>>a>>b; inp.pb(mp(a,b)); } recur(0); cout<<ans; 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...