zoukankan      html  css  js  c++  java
  • SCAU 8619 公约公倍

    8619 公约公倍

    时间限制:500MS  内存限制:1000K 提交次数:63 通过次数:19

    题型: 编程题   语言: 无限制

    Description

    给定六个正整数a,b,c,d,e,f;问你是否存在整数既是a,b,c的最大公约的倍数,同时又是d,e,f的最小公倍数的约数。

    Input

    输入为多case输入,每个case只有一行,每行六个正整数。当输入6个0时结束。

    Output

    存在输出YES,否则输出:NO

    Sample Input

    32 40 16 20 30 24
    0 0 0 0 0 0
    
    

    Sample Output

    YES

    Hint

    32,40,16的最大公约数是:8;而20,30,24的最小公倍数为120,显然存在整数(如24),既是8的倍数,又是120的约数

    Source

    jiangju0

    Provider

    admin

     

    #include<stdio.h>
    int max_int(int m, int n)
    {
        int temp;
        if(m<n) {temp = m; m = n; n = temp;}
        while(m%n != 0)
        {
            temp = m%n;
            m = n;
            n = temp;
        }
        return n;
    }
    
    int main()
    {
        int a, b, c, d, e, f;
        int  min, max;
        int temp;
        while(scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f))
        {
            if(!a && !b && !c && !d && !e && !f) break;
            max = max_int(a, b);
            max = max_int(max, c);
            min = max_int(d, e);
            temp = d*e/min;
            min = max_int(temp, f);
            temp = temp*f/min;
            if(temp%max == 0) printf("YES\n");
            else printf("NO\n");
        }
        return 0;
    } 

    解题报告:
    如果提交了,那就WA了,如果AC了,那么你找OJ的问题去

  • 相关阅读:
    背水一战 Windows 10 (26)
    背水一战 Windows 10 (25)
    背水一战 Windows 10 (24)
    背水一战 Windows 10 (23)
    背水一战 Windows 10 (22)
    背水一战 Windows 10 (21)
    背水一战 Windows 10 (20)
    背水一战 Windows 10 (19)
    背水一战 Windows 10 (18)
    背水一战 Windows 10 (17)
  • 原文地址:https://www.cnblogs.com/liaoguifa/p/2770410.html
Copyright © 2011-2022 走看看