hdoj-1562-Guess the number
来源:互联网 发布:主播猝死 知乎 编辑:程序博客网 时间:2024/05/16 11:44
Problem Description
Happy new year to everybody!
Now, I want you to guess a minimum number x betwwn 1000 and 9999 to let
(1) x % a = 0;
(2) (x+1) % b = 0;
(3) (x+2) % c = 0;
and a, b, c are integers between 1 and 100.
Given a,b,c, tell me what is the number of x ?
Input
The number of test cases c is in the first line of input, then c test cases followed.every test contains three integers a, b, c.
Output
For each test case your program should output one line with the minimal number x, you should remember that x is between 1000 and 9999. If there is no answer for x, output “Impossible”.
Sample Input
2
44 38 49
25 56 3
Sample Output
Impossible
2575
sabi题不解释啊
#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>using namespace std;int main(){ int a,b,c; int t; scanf("%d",&t); while(t--) { scanf("%d%d%d",&a,&b,&c); int cnt=0; for(int i=1000;i<=9999;i++) { if(i%a==0&&(i+1)%b==0&&(i+2)%c==0) { cnt=i; break; } } if(cnt!=0) printf("%d\n",cnt); else printf("Impossible\n"); } return 0;}
0 0
- hdoj-1562-Guess the number
- HDOJ 1562 Guess the number
- hdoj.1562 Guess the number 20140825
- 1562 Guess the number
- HDOJ(HDU) 1562 Guess the number(水题,枚举就行)
- hdu 1562 Guess the number
- hdu 1562 Guess the number
- HDU 1562 Guess the number
- HDU 1562 Guess the number
- HDU 1562 Guess the number
- hdu-oj 1562 Guess the number
- Guess the Number
- HDOJ1562 Guess the number
- EOJ 1095 Guess the Number
- hdu.1562.Guess the number
- 作业week2 'Guess the number'
- HDU 5981 Guess the number
- HDOJ Guess the number 3337【神题-抓取杭电后台输出数据】
- 创建第一个Django工程
- eclipse修改web名称报错
- win7 python2.7.10安装chardet
- MD5 32位加密
- mysql
- hdoj-1562-Guess the number
- centOS升级python3.5
- Learning to rank在淘宝的应用
- MIME 参考手册
- Exception和RuntimeException的区别
- Java学习笔记之抽象类
- sublime 安装phpcs
- Libcontainer Specification
- ubuntu下配置apache多端口网站