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 }
时间: 2024-10-13 19:56:08

HDU 5832 A water problem(某水题)的相关文章

HDU 5832 A water problem (水题,大数)

题意:给定一个大数,问你取模73 和 137是不是都是0. 析:没什么可说的,先用char 存储下来,再一位一位的算就好了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream>

HDU 5443 The Water Problem (水题,暴力)

题意:给定 n 个数,然后有 q 个询问,问你每个区间的最大值. 析:数据很小,直接暴力即可,不会超时,也可以用RMQ算法. 代码如下: #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include <queue

HDU 5832 A water problem 大数取余

A water problem Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 650    Accepted Submission(s): 333 Problem Description Two planets named Haha and Xixi in the universe and they were created with

HDU 5832 A water problem 【大数取模,Java 大数也不是万能的。。】

A water 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 whe

HDU 5832 A water problem(取模~)—— 2016中国大学生程序设计竞赛 - 网络选拔赛

传送门 A water problem Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 60    Accepted Submission(s): 37 Problem Description Two planets named Haha and Xixi in the universe and they were created wit

HDU 5832 A water problem

大数取模. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue> #in

HDU 1862 EXCEL排序 (排序水题)

Problem Description Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. Input 测试输入包含若干测试用例.每个测试用例的第1行包含两个整数 N (<=100000) 和 C,其中 N 是纪录的条数,C 是指定排序的列号.以下有 N 行,每行包含一条学生纪录.每条学生纪录由学号(6位数字,同组测试中没有重复的学号).姓名(不超过8位且不包含空格的字符串).成绩(闭区间[0, 100]内的整数)组成,每个项目间用1个空格隔开.当读到 N=0 时,全部输入结

HDU 4007 Dave (基本算法-水题)

Dave Problem Description Recently, Dave is boring, so he often walks around. He finds that some places are too crowded, for example, the ground. He couldn't help to think of the disasters happening recently. Crowded place is not safe. He knows there

HDU 1800 Flying to the Mars (水题)

Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11099    Accepted Submission(s): 3572 Problem Description In the year 8888, the Earth is ruled by the PPF Empire . As the popul