# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
897036 |
2024-01-02T13:08:33 Z |
AndrijaM |
Modsum (NOI12_modsum) |
C++17 |
|
1 ms |
436 KB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n;
vector<pair<long long,long long>>v;
cin>>n;
for(long long i=0;i<n;i++)
{
long long x,y;
cin>>x>>y;
v.push_back({x,y});
}
long long dp[n][5];
memset(dp,0,sizeof dp);
for(long long i=v[0].first;i<=v[0].second;i++)
{
dp[0][i%5]++;
}
for(long long i=1;i<n;i++)
{
for(long long mod=0;mod<5;mod++)
{
for(long long j=v[i].first;j<=v[i].second;j++)
{
dp[i][(mod+j)%5]+=dp[i-1][mod];
}
}
}
/*for(long long i=0;i<n;i++)
{
for(long long mod=0;mod<5;mod++)
{
cout<<dp[i][mod]<<" ";
}
cout<<endl;
}*/
cout<<4*(dp[n-1][1]+dp[n-1][4])+5*(dp[n-1][2]+dp[n-1][3])+dp[n-1][0]<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |