题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1562

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
 
Author
8600
 #include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
int T;
int a,b,c,x;
bool flag1,flag2,flag3;
cin>>T;
while(T--)
{
cin>>a>>b>>c;
flag1=false;flag2=false;flag3=false;
for(x=;x<=;x++)//预处理防止超时
{
if(x%a==)
{
flag1=true;
break;
}
}
if(flag1)
{
for(;x<=;x+=a)
{
if((x+)%b==&&(x+)%c==)
{
flag2=true;
cout<<x<<endl;
break;
}
}
}
if(!flag2)
cout<<"Impossible"<<endl;
}
return ;
}

HDU 1562 Guess the number的更多相关文章

  1. HDOJ(HDU) 1562 Guess the number(水题,枚举就行)

    Problem Description Happy new year to everybody! Now, I want you to guess a minimum number x betwwn ...

  2. HDU.1394 Minimum Inversion Number (线段树 单点更新 区间求和 逆序对)

    HDU.1394 Minimum Inversion Number (线段树 单点更新 区间求和 逆序对) 题意分析 给出n个数的序列,a1,a2,a3--an,ai∈[0,n-1],求环序列中逆序对 ...

  3. hdu 6216 A Cubic number and A Cubic Number【数学题】

    hdu 6216 A Cubic number and A Cubic Number[数学] 题意:判断一个素数是否是两个立方数之差,就是验差分.. 题解:只有相邻两立方数之差才可能,,因为x^3-y ...

  4. HDU 1394 Minimum Inversion Number(线段树求最小逆序数对)

    HDU 1394 Minimum Inversion Number(线段树求最小逆序数对) ACM 题目地址:HDU 1394 Minimum Inversion Number 题意:  给一个序列由 ...

  5. HDU 6093 - Rikka with Number | 2017 Multi-University Training Contest 5

    JAVA+大数搞了一遍- - 不是很麻烦- - /* HDU 6093 - Rikka with Number [ 进制转换,康托展开,大数 ] | 2017 Multi-University Tra ...

  6. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  7. HDU 1394 Minimum Inversion Number ( 树状数组求逆序数 )

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1394 Minimum Inversion Number                         ...

  8. HDU 1394 Minimum Inversion Number(线段树/树状数组求逆序数)

    Minimum Inversion Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java ...

  9. 【HDU 3709】 Balanced Number (数位DP)

    Balanced Number Problem Description A balanced number is a non-negative integer that can be balanced ...

随机推荐

  1. URL传值问题,不同浏览器对URL的长度要求

    通过URL传值的问题,所以对url字符串进行encodeURIComponent对url字符串内容进行编码,问题解决,但是有时候会出现 The request filtering module is ...

  2. mysql报错1024-can't get hostname for your address

    前一段时间mysql用的好好的,突然一天,mysql启动后,在使用navicat连接数据库的时候 报错1024-can't get hostname for your address 这里我是这样解决 ...

  3. jq屏蔽f5

    //屏蔽F5 $(document).ready(function () { $(document).bind("keydown", function (e) { e = wind ...

  4. Qt编译

    版本及安装环境 项目 版本 位 Windows 7 x64 Visual Studio 2010 x64 qt 4.8.6 x64 下载源码 进入下载列表,下载qt-everywhere-openso ...

  5. Linux下gcc,g++,gdb,scon部分用法笔记

    1 Ubuntu下编译安装GCC-4.1.2 拷贝gcc-4.1.2.tar.bz2(我下载的压缩文件)到/usr/local/src 解压 新生成的gcc-4.1.2这个目录被称为源目录,用${sr ...

  6. SUSE linux升级perl及openssl

    一.perl安装: 1.下载并解压软件:tar zxvf perl-5.24.0.tar.gz 2.运行./configure.gnu -help查看帮助,运行./configure.gnu -des ...

  7. CODE[VS]-求和-整数处理-天梯青铜

    题目描述 Description 求n个数的和 输入描述 Input Description 第一行一个整数n 接下来一行n个整数 输出描述 Output Description 所有数的和 样例输入 ...

  8. Linux的一些简单命令(三)

    1.解压缩算法:使用gzip算法进行解压缩,   压缩语法:gzip filename   解压语法:gzip -dv filename 2.解压缩算法:使用bzip2算法进行解压缩, 压缩语法:bz ...

  9. php取整

    php取整的方法一共有4中,分别是ceil(),floor(),round(),intval(). 1.ceil--向上取整,即不小于当前的下一个整数,如果有小数则进一位. 返回的是float类型 & ...

  10. CodeForces 711A Bus to Udayland

    简单题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #inclu ...