#include "message.h"
#include "futbol.h"
#include <bits/stdc++.h>
using namespace std;
long long n,k,p,w,l;
double h;
int main() {
if (MyNodeId()>0) return 0;
n=GetN(); k=GetK(); p=GetP();
w=1; l=1;
for (long long i=0; i<k; ++i) {
h=(n-i)/double(i+1);
h*=l;
l=round(h);
l%=p;
w+=l;
w%=p;
}
printf("%lld\n",w);
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include "message.h" #include "futbol.h" #include <bits/stdc++.h> using namespace std; long long n,k,p,w,l; double h; int main() { if (MyNodeId()>0) return 0; n=GetN(); k=GetK(); p=GetP(); w=1; l=1; for (long long i=0; i<k; ++i) { h=(n-i)/double(i+1); h*=l; l=round(h); l%=p; w+=l; w%=p; } printf("%lld\n",w); return 0; } |
English