分析:分析当整除(a+b)的时候肯定是后者胜利,假设余数不等于0的时候。假设余数大于b肯定是前者胜利,否则后者胜利。

代码:

import java.math.*;
import java.util.Scanner; public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
BigInteger n, a, b;
while(cin.hasNext()){
n = cin.nextBigInteger();
a = cin.nextBigInteger();
b = cin.nextBigInteger();
a = a.add(b);
n = n.mod(a);
//System.out.println(n);
if(n.compareTo(BigInteger.ZERO) == 0) System.out.println("Yougth");
else if(n.compareTo(b) > 0){
System.out.println("Yougth");
}
else System.out.println("Hrdv");
}
}
}

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=1077

05-24 09:21