Cod sursa(job #1351396)
| Utilizator | Data | 21 februarie 2015 10:56:37 | |
|---|---|---|---|
| Problema | Sum | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | 9neplace3 | Marime | 0.34 kb |
#include <fstream.h>
using namespace std;
int main()
{long s,N,P,r1,r2,r3;
ifstream f("suma.in");
f>>N;
f>>P;
f.close();
if((N-1)%3==0) r1=((N-1)/3)%P;
else r1=(N-1)%P;
if(N%3==0) r2=(N/3)%P;
else r2=N%P;
if((N+1)%3==0) r3=((N+1)/3)%P;
else r3=(N+1)%P;
s=(((r1*r2)%P)*r3)%P;
ofstream g("suma.out");
g<<s;
g.close();
return 0;
}
