#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int gcd(int a, int b) {
return b ? gcd(b, a % b) : a;
}
int main() {
int n;
cin >> n;
string a;
while (n -- ) {
cin >> a;
int pos = 0; // 不循环的位数
int POS = 0; // 循环的位数
bool flag = false; // 是否有循环
for (int i = 2; i < a.size(); i ++ ) {
if (!flag && a[i] >= '0' && a[i] <= '9')
pos ++ ;
if (a[i] == '(')
flag = true;
if (flag && a[i] >= '0' && a[i] <= '9')
POS ++ ;
}
int T = 0;
for (int i = 2; i <= pos + 1; i ++ )
T = T * 10 + (a[i] - '0');
if (!flag) {
int x = (int)pow(10, pos);
int y = gcd(T, x);
cout << T / y << '/' << x / y << endl;
} else {
int ans = 0;
for (int i = 2; i < a.size(); i ++ )
if (a[i] >= '0' && a[i] <= '9')
ans = ans * 10 + (a[i] - '0');
ans -= T;
int x = (int)pow(10, pos);
int X = (int)pow(10, a.size() - 4);
X -= x;
int y = gcd(ans, X);
cout << ans / y << '/' << X / y << endl;
}
}
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
vector<int> C;
void factor(int n)
{
C.push_back(1); // 如果n == 1 ,答案数组为1
for (int i = 2; i <= n; i ++) // n != 1 , 执行递归 乘法代码
{
int t = 0; // t 是进位
for (int j = 0; j < C.size(); j ++) // 遍历当前答案数组中的每一位
{
C[j] = C[j] * i + t;
t = C[j] / 10;
C[j] %= 10;
}
while (t)
{
C.push_back(t % 10);
t /= 10;
}
}
}
int main()
{
int n;
while (cin >> n)
{
C.clear(); // 每次算阶乘之前要清空答案数组
factor(n);
for (int i = C.size() - 1; i >= 0; i --) cout << C[i];
cout << endl;
}
return 0;
}
#include <iostream>
#include <cmath>
using namespace std;
typedef long long LL;
const int N = 35000;
LL a[N];
LL s[N];
void init() {
a[1] = s[1] = 1;
for (int i = 2; i < N; i ++ ) {
a[i] = a[i - 1] + (int)log10((double)i) + 1;
s[i] = s[i - 1] + a[i];
}
}
int solve(int n) {
int i = 1;
while (s[i] < n) {
i ++ ;
}
int pos = n - s[i - 1];
int len = 0;
for (i = 1; len < pos; i ++ )
len += (int)log10((double)i) + 1;
return (i - 1) / (int)pow((double)10, len - pos) % 10;
}
int main() {
init();
int t;
cin >> t;
while (t -- ) {
int n;
cin >> n;
cout << solve(n) << endl;
}
return 0;
}
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int f[21] = {0, 1, 1};
void init() {
for (int i = 3; i < 21; i ++ )
f[i] = f[i - 1] + f[i - 2];
}
int main() {
init();
int n;
while (cin >> n) {
if (n <= 20) {
cout << f[n] << endl;
continue;
} else {
double temp = -0.5 * log(5.0) / log(10.0) + ((double)n) * log((sqrt(5.0) + 1.0) / 2.0) / log(10.0);
temp -= floor(temp);
temp = pow(10.0, temp);
while (temp < 1000)
temp *= 10;
cout << (int)temp << endl;
}
}
return 0;
}
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double n, p;
while (cin >> n >> p) {
cout << pow(p, 1.0 / n) << endl;
}
return 0;
}