mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
24 lines
419 B
C++
24 lines
419 B
C++
|
#include<iostream>
|
||
|
#include<cstdio>
|
||
|
int main()
|
||
|
{
|
||
|
int T;
|
||
|
scanf("%d",&T);
|
||
|
while(T--)
|
||
|
{
|
||
|
int n,k;
|
||
|
scanf("%d%d",&n,&k);
|
||
|
if(n<k)
|
||
|
printf("0\n");
|
||
|
else
|
||
|
{
|
||
|
int l=n%k;
|
||
|
if(l<=k/2)
|
||
|
printf("%d\n",n*n-l*l);
|
||
|
else
|
||
|
printf("%d\n",n*n-(k-l)*(k-l));
|
||
|
}
|
||
|
}
|
||
|
return 0;
|
||
|
}
|