Cod sursa(job #1055204)
Utilizator | Popescu Silviu crushack | Data | 14 decembrie 2013 11:01:02 |
---|---|---|---|
Problema | Progresie | Scor | 0 |
Compilator | cpp | Status | done |
Runda | ONIS 2014, Runda 1 | Marime | 0.52 kb |
#include <stdio.h>
const char IN[] = "progresie.in", OUT[] = "progresie.out";
int Tes, N, R;
long long len;
int main() {
freopen(IN, "r", stdin);
scanf("%d", &Tes);
freopen(OUT, "w", stdout);
while ( Tes -- ) {
scanf("%d%d", &N, &R);
if ( N == 1 ) {
printf("1\n");
continue;
}
if ( N == 2 ) {
printf("%d\n", N * ( N - 1) + N);
continue;
}
len = 1LL * ( N - 1) * R + 1;
printf("%lld\n", 1 + len * (len - 1));
}
fclose(stdout);
fclose(stdin);
return 0;
}