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,否则输出:NOSample 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的问题去
更多内容请关注个人微信公众号 物役记 (微信号:materialchains)
作者:雪影蓝枫
本文版权归作者和博客园共有,欢迎转载,未经作者同意须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。