首页 > 其他 > 详细

FZU 2193 So Hard

时间:2015-05-14 14:00:25      阅读:133      评论:0      收藏:0      [点我收藏+]
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
char s[20];
long long t, y;
long long gcd(long long a, long long b)
{
    long long  t;
    while (b)
    {
        t = a%b;
        a = b;
        b = t;
    }
    return a;
}
int main()
{
    int sb;
    scanf("%d", &sb);
    while (sb--)
    {
        long long i;
        scanf("%s", s);
        t = 0, y = 0;
        long long  len = strlen(s);
        for (i = 0; i < len; i++)
        {
            if (s[i] == .) break;
            t = t * 10 + s[i] - 0;
        }
        long long o = 0;
        for (; i < len; i++)
        {
            if (s[i] == .) continue;
            y = y * 10 + s[i] - 0;
            o++;
        }
        long long e = 1;
        for (i = 1; i <= o; i++) e = e * 10;
        printf("%lld/%lld\n", (t*e + y) / gcd(t*e + y, e), (e) / gcd(t*e + y, e));
    }
    return 0;
}

 

FZU 2193 So Hard

原文:http://www.cnblogs.com/zufezzt/p/4503055.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!