Submission #26801

# Submission time Handle Problem Language Result Execution time Memory
26801 2017-07-06T05:21:16 Z sutekine Modsum (NOI12_modsum) C++11
25 / 25
0 ms 2228 KB
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#define oo 987654321
using namespace std;

int n, s[1010], e[1010], dt[1010][10], ans = 1;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 1 ; i <= n ; i++ ) cin>>s[i]>>e[i], ans *= (e[i]-s[i]+1);
    for(int i = 1 ; i <= n ; i++ )
        for(int j = s[i] ; j <= e[i] ; j++ )
        {
            if( i == 1 ) dt[i][j%5] += 1;
            else
            {
                for(int k = 0 ; k < 5 ; k++ )
                    dt[i][k] += dt[i-1][(5+(k-(j%5)))%5];
            }
        }
    for(int i = 0 ; i < 5 ; i++ )
        ans += ((2*(i*i)+(i*i*i*i))%5)*dt[n][i];
    cout<<ans<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2228 KB Output is correct
2 Correct 0 ms 2228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2228 KB Output is correct
2 Correct 0 ms 2228 KB Output is correct
3 Correct 0 ms 2228 KB Output is correct
4 Correct 0 ms 2228 KB Output is correct
5 Correct 0 ms 2228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2228 KB Output is correct
2 Correct 0 ms 2228 KB Output is correct
3 Correct 0 ms 2228 KB Output is correct
4 Correct 0 ms 2228 KB Output is correct
5 Correct 0 ms 2228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2228 KB Output is correct
2 Correct 0 ms 2228 KB Output is correct
3 Correct 0 ms 2228 KB Output is correct
4 Correct 0 ms 2228 KB Output is correct
5 Correct 0 ms 2228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2228 KB Output is correct
2 Correct 0 ms 2228 KB Output is correct
3 Correct 0 ms 2228 KB Output is correct
4 Correct 0 ms 2228 KB Output is correct
5 Correct 0 ms 2228 KB Output is correct