// http://www.spoj.com/problems/CANTON/
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
int t;
cin >> t;
while (t-- >0) {
int n;
cin >> n;
int approacher = 1;
int x = 1;
int y = 1;
int step = 1;
while (approacher <= n) {
if (approacher+step > n) {
break;
} else {
approacher += step;
step++;
}
}
x = step;
int diff = n - approacher;
int t = 0;
if (x%2==0) {
t = y;
y = x;
x = t;
x += diff;
y -= diff;
} else {
x -= diff;
y += diff;
}
cout << "TERM " << n << " IS " << x << "/" << y << endl;
}
}
Count on Cantor
最新推荐文章于 2020-07-22 09:30:41 发布