AP - Complete The Series (Easy)
Link to the question : AP2
HINT :
Simply apply the formulae that you have learnt in your elementary school. A very easy question on arithmetic progression , even the question states it. But dont forget to simplify the equations a bit if you dont want your code to be a bit messy.
SOURCE CODE :
#include<stdio.h>
int main()
{
int t;
long long int sum, n3,l3,a,d,i,n;
scanf("%d",&t);
while(t--)
{
scanf("%lld %lld %lld",&n3,&l3,&sum);
n= (2*sum)/(n3+l3);
d= (l3-n3)/(n-5);
a= n3 - 2*d;
printf("%lld\n",n);
for(i=1;i<=n;i++)
{
printf("%lld ",a);
a= a+d;
}
printf("\n");
}
return 0;
}
No comments:
Post a Comment