problem statement is here
#include<stdio.h>
int main()
{
long long int t,a,b,c,i,j,k;
scanf("%lld",&t);
while(t--){
scanf("%lld",&a);
for(i=0; ;i++){
if(((i*(i+1))/2)<a && a<=(((i+1)*(i+2))/2) ){
b=a-((i*(i+1))/2);
break;
}
}
c=i+1;
if(c%2==0){
j=b;
k=c+1-b;
}else{
j=c+1-b;
k=b;
}
printf("TERM %lld IS %lld/%lld\n",a,j,k);
}
return 0;
}
No comments:
Post a Comment