• Finding LCM LightOJ


    这题和这题一样。。。。。。只不过多了个数。。。

    Finding LCM

     LightOJ - 1215 

    https://www.cnblogs.com/WTSRUVF/p/9316412.html

    #include <iostream>
    #include <cstdio>
    #include <sstream>
    #include <cstring>
    #include <map>
    #include <set>
    #include <vector>
    #include <stack>
    #include <queue>
    #include <algorithm>
    #include <cmath>
    #define rap(a, n) for(int i=1; i<=n; i++)
    #define MOD 2018
    #define LL long long
    #define ULL unsigned long long
    #define Pair pair<int, int>
    #define mem(a, b) memset(a, b, sizeof(a))
    #define _  ios_base::sync_with_stdio(0),cin.tie(0)
    //freopen("1.txt", "r", stdin);
    using namespace std;
    const int maxn = 10010, INF = 0x7fffffff;
    LL gcd(LL a, LL b)
    {
        return b==0?a:gcd(b, a%b);
    }
    
    int main()
    {
        int T, kase = 0;
        cin>> T;
        while(T--)
        {
            LL a, b, L;
            cin>> a >> b >> L;
            printf("Case %d: ", ++kase);
            LL c = a * b / gcd(a, b);
            if(L % c)
            {
                cout<< "impossible" <<endl;
                continue;
            }
            LL d = L / c;
            while(gcd(c, d) != 1)
            {
                LL m = gcd(c, d);
                c /= m;
                d *= m;
            }
            cout<< d <<endl;
        }
    
        return 0;
    }
    自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也能够保持自己的本色走下去。
  • 相关阅读:
    ssh免密码登录与常见问题
    在eclipse中生成实体类
    在cmd中设置字体
    java命名
    c/s架构
    sql身份证号查人数
    bootstraptable表格基本
    手机登录验证
    form表单验证提示语句
    html让背景透明
  • 原文地址:https://www.cnblogs.com/WTSRUVF/p/9350242.html
Copyright © 2020-2023  润新知