Cod sursa(job #1527157)
Utilizator | Data | 17 noiembrie 2015 21:30:09 | |
---|---|---|---|
Problema | Zeap | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.25 kb |
#include <fstream>
using namespace std;
ifstream fin("suma.in");
ofstream fout("suma.out");
long long n,p,x;
int main()
{
fin>>n>>p;
n--;
n=n%p;
x=((n + 1)*n/2)%p + (((n + 1) * n)*(2 * n + 1)/6)%p;
fout<<x%p;
return 0;
}