/***
Md. Namzul Hasan
Shahjalal University of Sciency & technology,sylhet.
hasan08sust@gmail.com
verdict: accepted
***/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<cmath>
#include<sstream>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
int main()
{
in n ;
while(cin>>n)
{
in a=1 , b=1 , l=1 , m=0;
in count =1 ;
if(n==1)
{
pf("TERM %d IS %d/%d\n",n,a,b) ;
continue ;
}
while(1)
{
if(l==1)
{
b++ ;
l =0 ;
count++ ;
if(count==n)
{
m=1 ;
break ;
}
for(in i =1 ; ; i++)
{
a++ ;
b-- ;
// pf("%d /%d- ",a,b) ;
count++ ;
if(count==n)
{
m=1 ;
break ;
}
else if(b==1)
break ;
}
//cout<<endl ;
}
else if(l==0)
{
a++ ;
// pf("%d /%d ",a,b) ;
l=1 ;
count++ ;
if(count==n)
{
m=1 ;
break ;
}
for(in i=1 ;; i++)
{
a-- ;
b++ ;
// pf("%d /%d ",a,b) ;
count++ ;
if(count==n)
{
m=1 ;
break ;
}
else if(a==1)
break ;
}
//cout<<endl ;
}
if(m==1)
break ;
}
pf("TERM %d IS %d/%d\n",n,a,b) ;
}
return 0 ;
}
Md. Namzul Hasan
Shahjalal University of Sciency & technology,sylhet.
hasan08sust@gmail.com
verdict: accepted
***/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<cmath>
#include<sstream>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
int main()
{
in n ;
while(cin>>n)
{
in a=1 , b=1 , l=1 , m=0;
in count =1 ;
if(n==1)
{
pf("TERM %d IS %d/%d\n",n,a,b) ;
continue ;
}
while(1)
{
if(l==1)
{
b++ ;
l =0 ;
count++ ;
if(count==n)
{
m=1 ;
break ;
}
for(in i =1 ; ; i++)
{
a++ ;
b-- ;
// pf("%d /%d- ",a,b) ;
count++ ;
if(count==n)
{
m=1 ;
break ;
}
else if(b==1)
break ;
}
//cout<<endl ;
}
else if(l==0)
{
a++ ;
// pf("%d /%d ",a,b) ;
l=1 ;
count++ ;
if(count==n)
{
m=1 ;
break ;
}
for(in i=1 ;; i++)
{
a-- ;
b++ ;
// pf("%d /%d ",a,b) ;
count++ ;
if(count==n)
{
m=1 ;
break ;
}
else if(a==1)
break ;
}
//cout<<endl ;
}
if(m==1)
break ;
}
pf("TERM %d IS %d/%d\n",n,a,b) ;
}
return 0 ;
}
No comments:
Post a Comment