• SDNU 1254.Problem B. SOS(水题)


    Description

    Lulichuan is a good captain, He is thinking every day how to make his team stronger,However, his team members always disappointed him.They always make mistakes, like WA, TLE, MLE, CE,PE.....Today, he thought of a good way to make team members stronger. That is to make the peoblem simpler. So he got a easy problem, now, we have three numbers, a, b, c,

    We know gcd(a,c) = b,  but, we lose the c, we only know a, b, b != c,we want to know the smallest c.

    (0 < a, b, c< 10000000)

    Input

     T(0 < T <= 10000) T is TestCase

     a, b(0 < a, b<=10000000)

    Output

     Case #TestCase: answer

    Sample Input

    2
    6 2
    12 4

    Sample Output

    Case #1: 4
    Case #2: 8

    Source

    Unknown
    #include <cstdio>
    #include <iostream>
    #include <cmath>
    #include <string>
    #include <cstring>
    #include <algorithm>
    #include <queue>
    #include <vector>
    #include <map>
    using namespace std;
    #define ll long long
    
    int t, a, b, c;
    
    int gcd(int a, int b)
    {
        if(a%b == 0)return b;
        return gcd(b, a%b);
    }
    
    int main()
    {
        scanf("%d", &t);
        int miao = t;
        while(t--)
        {
            scanf("%d%d", &a, &b);
            c = b*2;
            while(gcd(a, c) != b)c += b;
            printf("Case #%d: %d
    ", miao-t, c);
        }
        return 0;
    }
  • 相关阅读:
    Android-adb相关
    我想和iOS大牛们交流的问题
    iOS应用 bug定位
    iOS 中Block的基础用法
    iOS9 耗电量惊人
    三人小团队git分支协作试水
    今天开通了博客
    解决XCode安装插件后插件不能使用的问题(转载)
    (转载)iOS- 指压即达,如何集成iOS9里的3D Touch
    人魔七七
  • 原文地址:https://www.cnblogs.com/RootVount/p/10993078.html
Copyright © 2020-2023  润新知