Cod sursa(job #1348979)
Utilizator | Data | 19 februarie 2015 22:10:44 | |
---|---|---|---|
Problema | Progresie | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva ICPC | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
#include <cstdio>
using namespace std;
int t,n,r;
int main()
{int i,j,x;
ifstream f("progresie.in");
FILE *g;
g=fopen("progresie.out","w");
f>>t;
for(i=1;i<=t;i++)
{
f>>n>>r;
if(r==1)
fprintf(g,"%d\n",n*n*r*r-n*r+1);
else
fprintf(g,"%d\n",n*n*(r-1)*(r-1)-n*(r-1)+1);
}
return 0;
}