题目链接: 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. JSON反序列化实体类

    1.定义实体类 [DataContract] public class CustomerWordOrderViewModel { [DataMember] public string Name; [D ...

  2. Ubuntu16.04 server下配置MySQL,并开启远程连接

    背景 最近正在学nodejs,想到曾经有台云服务器,但是很久不用了,由于怕麻烦,一股脑的把云主机重装了个Ubuntu系统,于是配置MySQL成了配置服务中的一个环节(node用不用MySQL不管,主要 ...

  3. PHP5.6通过CURL上传图片@符无效的兼容问题

    今天本来想试试一个图片云的API,于是本地做了个上传图片的测试,结果灰常郁闷的发现以前一直用的好好的CURL上传图片居然死活不起作用,本来几分钟搞定的事情,结果折腾了大半天才终于找到原因,居然是兼容性 ...

  4. liunx服务器常见监控指标

    1. CPU Utilization 英文翻译就是CPU的利用率75%以上就比较高了(也有说法是80%或者更高).有的博客上说除了这个指标外,还要结合Load Average和Context Swit ...

  5. python reduce使用实例

    通过一个简单的算法来了解reduce的巧用. 构建函数persistence(n),如果n>9,则返回0.否则继续根据n的权重来分解n,如n=999,则分解为9,9,9.那么将9*9*9=729 ...

  6. 转:Spark User Defined Aggregate Function (UDAF) using Java

    Sometimes the aggregate functions provided by Spark are not adequate, so Spark has a provision of ac ...

  7. 关于wkwebview

    一.引入库 #import <WebKit/WebKit.h> 二.初始化有两种方式 // 默认初始化 - (instancetype)initWithFrame:(CGRect)fram ...

  8. java模拟数据库缓存

    实现缓存一些数据到本地,避免重复查询数据库,对数据库造成压力,代码如下: package threadLock; import java.util.HashMap; import java.util. ...

  9. linux/windows平台生成随机数的不同方法

    linux平台,使用rand.Seed() //rand_linux.go package main import ( "math/rand" "time" ) ...

  10. Python学习笔记——基础篇【第七周】———类的静态方法 类方法及属性

    新式类和经典类的区别 python2.7 新式类——广度优先 经典类——深度优先 python3.0 新式类——广度优先 经典类——广度优先 广度优先才是正常的思维,所以python 3.0中已经修复 ...