2020-09-12
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
ll k,l;
scanf("%lld%lld",&k,&l);
ll max1;
int flag=-1,f=-1;
for(int i=l;i<2000&&flag==-1;i++)
{
if(i%2)
{
ll p=(i-1)/2;
double d=(k+p*i)*1.0/(i-1);
ll w=d;
if(d==w)
{
if(w<=1e6&&w>=1)
flag=w,f=i;
}
}
else
{
ll p=i/2;
double d=(k+p*i)*1.0/(i-1);
ll w=d;
if(d==w)
{
if(w<=1e6&&w>=1)
flag=w,f=i;
}
}
}
if(flag==-1)
{
cout<<-1<<endl;
continue;
}
cout<<f<<endl;
int x;
if(f%2==0)
{
x=-1;
}
else
{
x=0;
}
for(int i=1;i<f;i++)
{
cout<<x<<' ';
if(x==-1)
x=0;
else
x=-1;
}
cout<<flag<<endl;
}
return 0;
}
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll n,m,k,sum=0;
scanf("%lld%lld%lld",&n,&m,&k);
if(n>m)
{
sum=sum+m*(m-1)/2;
ll last=n-m+1;
ll time=last/k;
if(last%k)
time++;
sum+=(m-1)*time;
sum+=(time-1)*last+(time-1)*(time-2)*(-k)/2;
sum+=last%k;
}
else
{
sum=n*(n+1)/2;
}
cout<<sum<<endl;
return 0;
}