This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(lli i = (a); i <= (b); i++)
#define repa(i,a,b) for(lli i = (a); i >= (b); i--)
#define pll pair<lli,lli>
#define mod 1000000007
lli a,b,n,res,act;
lli expo(lli num, lli pot) {
lli res = 1;
while (pot) {
if (pot&1) {
res *= num;
res %= mod;
}
num *= num;
num %=mod;
pot /= 2;
}
return res;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
rep(i,1,n) cin >> a >> b;
act = 1;
res = 0;
rep(i,0,n) {
res += act*i;
res %= mod;
act *= (n-i);
act %= mod;
act *= expo(i+1,mod-2);
act %= mod;
//debugsl(act);
//debugsl(i);
//debug(res);
}
cout << res;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |