#include<stdio.h>
#include<string.h>
#include
#include
#include
const long long inf=1e17;
#define forn(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
ll mod=pow(10,9)+7;
int main(){
int t;
ll x,n,p;
scanf("%d",&t);
while(t–){
scanf("%lld",&x);
n=ceil(sqrt(8*x+1))/2;
p=(pow(n,2)+n)/2;
if(!(n%2))
printf(“TERM %d IS %d/%d\n”,x,n-p+x,p+1-x);
else
printf(“TERM %d IS %d/%d\n”,x,p+1-x,n-p+x);
}
return 0;
}
Please post your ideone link or please change the style of representing it. It’s really hard to read or understand the code,the way it’s written.
As we can see,Here
but you forgot to use the ‘-1’.
Here’s the solution. Check out.