标签:scan efi amp panel problem ide 输出 没有 lap
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1717
1 #include<stdio.h> 2 #include<string.h> 3 #define LL long long 4 5 char s[20]; 6 7 LL GCD(LL a, LL b)//求最大公约数 8 { 9 LL c; 10 while(b) 11 { 12 c = a % b; 13 a = b; 14 b = c; 15 } 16 return a; 17 } 18 19 int main() 20 { 21 int T; 22 scanf("%d", &T); 23 while(T --) 24 { 25 LL x = 0, y = 1; 26 int flag = 0, id; 27 scanf("%s", s); 28 int len = strlen(s); 29 for(int i = 2; i < len; i ++) 30 { 31 if(s[i] == ‘(‘) 32 { 33 flag = 1; 34 id = i; 35 break; 36 } 37 x = x * 10 + (s[i] - ‘0‘);//分子扩大多少 38 y *= 10;//分母就除去多少 39 } 40 if(flag == 0) //没有循环小数 41 { 42 LL temp = GCD(x, y); 43 printf("%lld/%lld\n", x / temp, y / temp); 44 } 45 else //有循环小数 利用循环小数的性质求解 46 { 47 LL xx = x, yy = y; 48 id ++; 49 for(int i = id; i < len; i ++) 50 { 51 if(s[i] == ‘)‘) 52 continue; 53 xx = xx * 10 + (s[i] - ‘0‘); 54 yy *= 10; 55 } 56 LL a = xx - x; 57 LL b = yy - y; 58 LL temp = GCD(a, b); 59 printf("%lld/%lld\n", a / temp, b / temp); 60 } 61 } 62 return 0; 63 }
标签:scan efi amp panel problem ide 输出 没有 lap
原文地址:https://www.cnblogs.com/yuanweidao/p/11269670.html