HDU 5832 A water problem(某水题)

HDU 5832 A water problem某水题

Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

 

Problem Description - 题目描述

Two planets named Haha and Xixi in the universe and they were created with the universe beginning.
 
There is 73 days in Xixi a year and 137 days in Haha a year. 
 
Now you know the days N after Big Bang, you need to answer whether it is the first day in a year about the two planets.
宇宙之中有Haha与Xixi两星,鸿蒙时代既存。

Xixi一年73天,Haha一年137天

现在你被告知宇宙大爆炸后已过N天,待你断定这是否是两颗星球一年中的第一天。
CN

 

Input - 输入

There are several test cases(about 5 huge test cases). 
 
For each test, we have a line with an only integer N(0≤N), the length of N is up to 10000000.
多组测试用例(大约5组特大数据)。

对于每组测试用例,给出一行仅有一个整数N(0≤N),N的长度高达10000000。
CN

 

Output - 输出

For the i-th test case, output Case #i: , then output "YES" or "NO" for the answer.

对于第i个测试用例,先输出Case #i: ,再输出回答"YES""NO"
CN

 

Sample Input - 输入样例

10001
0
333

 

Sample Output - 输出样例

Case #1: YES
Case #2: YES
Case #3: NO

 

题解

  大数取模

  类似输入挂的读取方式,不过直接按照输入挂的做法读取一个字符处理一次IO开销太大,会超时,先保存进数组再处理可以极大地提高速度。

 

代码 C++

 1 #include <cstdio>
 2 #define mod 10001
 3 char data[10000005];
 4 int main(){
 5     int n, i = 0, j;
 6     while (gets(data)){
 7         printf("Case #%d: ", ++i);
 8         for (j = n = 0; data[j]; ++j) n = (n * 10 + data[j] - '0') % mod;
 9         if (n == 0) puts("YES");
10         else puts("NO");
11     }
12     return 0;
13 }


 

 

原文地址:https://www.cnblogs.com/Simon-X/p/5998881.html