A Water problem Description
The planets named Haha and Xixi in the universe and they were created with the universe beginning.
There is the year of Xixi A and 137 days in Haha a.
Now you know the day N after Big Bang, you need to answer whether it's the first day of a year on about the the-the-same planets.
Input
There is several test cases (about 5 huge test cases).
For each test, we had a line with an only integer N (0≤n) and the length of n is up to 10000000.
Output
For the i-th test case, output case #i: And then output "YES" or "NO" for the answer.
Sample Input
10001
0
333
Sample Output
Case #1: YES
Case #2: YES
Case #3: NO
Topic Connection:
http://acm.hdu.edu.cn/showproblem.php?pid=5832
Test instructions
I'll give you a number and ask if you can divide the number by 137 and 73.
Exercises
These two number coprime, is actually asks you whether can divide 10001 (73*137,)
Just sweep it all over again.
Using string may be tle, so just use char.
Java is the MLE, it seems that Java is not omnipotent,
AC Code:
#include <iostream> #include <cstdio> #include <cstring>using namespace Std;char a[10000005];int Main () { int kase=0; int n; Freopen ("Data/5832.txt", "R", stdin); while (Cin>>a) { printf ("Case #%d:", ++kase); int Len=strlen (a); int mod=0; for (int i=0;i<len;i++) { mod= (mod*10+a[i]-' 0 ')%10001; } if (mod==0) cout<< "YES" <<endl; else cout<< "NO" <<endl; } return 0;}
Java MLE Code:
Import Java.math.biginteger;import Java.util.scanner;public class Main {public static void Main (string[] args) {
//TODO auto-generated Method stub Scanner sc = new Scanner (system.in); int kase = 0; while (Sc.hasnext ()) { BigInteger a = Sc.nextbiginteger (); BigInteger mod = biginteger.valueof (10001); BigInteger ans = a.mod (mod); System.out.printf ("Case #%d:", ++kase); if (Ans.equals (Biginteger.zero)) { System.out.println ("YES"); } else{ System.out.println ("NO");}}}
HDU 5832 A Water Problem "large number of models, Java large number is not omnipotent. 】