#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> a(10000);
int main(){
int n;
for(int i=1;i<10000;i++){
a[i]=a[i-1]+i;
}
while(cin>>n){
vector<int>::iterator it=lower_bound(a.begin(),a.end(),n);
int rem=n-*(it-1)-1,num,den;
if(((it-a.begin())&1)==0){
num=1,den=it-a.begin();
num+=rem,den-=rem;
}
else{
num=it-a.begin(),den=1;
num-=rem,den+=rem;
}
cout<<"TERM "<<n<<" IS "<<num<<"/"<<den<<endl;
}
}
#include <vector>
#include <algorithm>
using namespace std;
vector<int> a(10000);
int main(){
int n;
for(int i=1;i<10000;i++){
a[i]=a[i-1]+i;
}
while(cin>>n){
vector<int>::iterator it=lower_bound(a.begin(),a.end(),n);
int rem=n-*(it-1)-1,num,den;
if(((it-a.begin())&1)==0){
num=1,den=it-a.begin();
num+=rem,den-=rem;
}
else{
num=it-a.begin(),den=1;
num-=rem,den+=rem;
}
cout<<"TERM "<<n<<" IS "<<num<<"/"<<den<<endl;
}
}
Comments
Post a Comment