제출 #1168924

#제출 시각아이디문제언어결과실행 시간메모리
1168924hamzabc나머지들의 합 (NOI12_modsum)C++20
25 / 25
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define mod 1000000007 #define sp << " " << #define endl << '\n' long long int N; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> N; vector<long long> rt(5), rt2(5); rt[0] = 1; for (int i = 0; i < N; i++){ long long a, b; cin >> a >> b; for (int o = 0; o < 5; o++) rt2[(o + a % 5) % 5] = rt[o] * ((b - a + 5) / 5); for (int o = 0; o < 5; o++) rt2[(o + a % 5 + 1) % 5] += rt[o] * ((b - a + 4) / 5); for (int o = 0; o < 5; o++) rt2[(o + a % 5 + 2) % 5] += rt[o] * ((b - a + 3) / 5); for (int o = 0; o < 5; o++) rt2[(o + a % 5 + 3) % 5] += rt[o] * ((b - a + 2) / 5); for (int o = 0; o < 5; o++) rt2[(o + a % 5 + 4) % 5] += rt[o] * ((b - a + 1) / 5); swap(rt, rt2); } long long a = 0; for (int i = 0; i < 5; i++){ a += ((i * i * i * i + 2 * i * i) % 5 + 1) * rt[i]; } cout << a; }
#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...