#include <iostream>
using namespace std;
typedef long long ll;
const int MAXN = 1007;
ll n, ans = 0;
ll a[MAXN], b[MAXN];
void rec(ll ind, ll temp){
if(ind == n)
ans += (temp*temp*temp*temp + 2*temp*temp) % 5 + 1;
for(ll i = a[ind]; i <= b[ind]; i++)
rec(ind+1, temp+i);
}
int main()
{
cin >> n;
for(int i = 0; i < n; i++)
cin >> a[i] >> b[i];
rec(0, 0);
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
163 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
120 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
51 ms |
332 KB |
Output is correct |
4 |
Correct |
6 ms |
300 KB |
Output is correct |
5 |
Correct |
190 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
20 ms |
360 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
51 ms |
356 KB |
Output is correct |