Submission #516957

# Submission time Handle Problem Language Result Execution time Memory
516957 2022-01-22T09:14:11 Z sudheerays123 Modsum (NOI12_modsum) C++
25 / 25
132 ms 420 KB
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define tc ll test;cin >> test;while(test--)
#define vi vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define INF 1e18
#define MOD 1000000007
#define ff first
#define ss second
#define in >>
#define out <<
#define space << " " <<
#define spacef << " "
#define fo(i,a,b) for(ll i = a; i <= b; i++)
#define nextline out "\n"
#define print(x) for(auto i : x ) cout out i spacef
#define mmax(x,i) x = max(x,i)
#define mmin(x,i) x = min(x,i)
#define N 1005

ll f(ll x){

	ll y = (((x*x)%5)*((x*x)%5))%5;
	y += (2*x*x)%5;
	y %= 5;

	y++;

	return y;
}

vi val(N);
ll sum = 0;
vector<pll> a(N);
ll n;

void go(ll i){

	if(i == n+1){
		ll s = 0;
		fo(k,1,n) s += val[k];

		sum += f(s);
		return;
	}

	fo(j,0,a[i].second-a[i].first){
		ll x = val[i];
		val[i] += j;
		go(i+1);
		val[i] = x;
	}
}

int main() {
    
    fast;

	cin in n;

	fo(i,1,n){
		cin in a[i].first in a[i].second;
		val[i] = a[i].first;
	}
	
	go(1);

	cout out sum;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 6 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 8 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 13 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 420 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 100 ms 380 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 132 ms 336 KB Output is correct