Cod sursa(job #1056797)
Utilizator | Data | 14 decembrie 2013 13:39:32 | |
---|---|---|---|
Problema | Progresie | Scor | 0 |
Compilator | cpp | Status | done |
Runda | ONIS 2014, Runda 1 | Marime | 0.45 kb |
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
freopen("progresie.in","r",stdin);
freopen("progresie.out","w",stdout);
long long int nr,T,N,R,k,j;
cin >> T;
for(int i=0;i<T;i++)
{
cin >> N >> R;
k=R*(N-1)+1;
j=1;
nr=1;
while(nr<k)
{
j+=2*nr;
nr++;
}
cout <<j << endl;
}
return 0;
}