HDOJ 1562 Guess the number

来源:互联网 发布:linux中80端口被占用 编辑:程序博客网 时间:2024/05/16 07:06

HDACM 1562

水题…

import java.util.Scanner;public class Main {    public static void main(String[] args) {        Scanner sc = new Scanner(System.in);        int n = sc.nextInt();        while (n-->0) {            int a = sc.nextInt();            int b = sc.nextInt();            int c = sc.nextInt();            int i = (1000/a+1)*a;            for (; i < 10000; i+=a) {                if ((i+1)%b==0 && (i+2)%c==0) {                    System.out.println(i);                    break;                }            }            if (i>=10000) {                System.out.println("Impossible");            }        }        sc.close();    }}
原创粉丝点击