Submission #197518

#TimeUsernameProblemLanguageResultExecution timeMemory
197518handlenameModsum (NOI12_modsum)C++17
25 / 25
3 ms504 KiB
#include <bits/stdc++.h> using namespace std; int sum[1001][5]; int main() { int n; cin>>n; sum[0][0]=1; for (int i=1;i<=n;i++){ int a,b; cin>>a>>b; for (int j=a;j<=b;j++){ int c=j%5; for (int k=0;k<5;k++){ sum[i][k]+=sum[i-1][(k+c)%5]; } } } int ans=0; for (int i=0;i<5;i++){ ans+=sum[n][i]*(((i*i*i*i+2*i*i)%5)+1); } cout<<ans; }
#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...