CCPC网赛,HDU5832_ A water problem

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.

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.

Output

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

Sample Input

10001

0

333

Sample Output

Case #1: YES

Case #2: YES

Case #3: NO

代码如下:

 1 #include<cstdio>
 2 #include<cstring>
 3 #define N 10000001
 4 char s[N];
 5 int main()
 6 {
 7     long long mod;
 8     int len;
 9     int n=10001;
10     int kk=1;
11        while(scanf("%s",s)!=EOF)
12        {
13            len=strlen(s);
14            mod=0;
15            for(int i=0; i<len; i++)
16            {
17                mod=mod*10+s[i]-‘0‘;
18                mod=mod%n;
19            }
20            if(mod==0){
21                printf("Case #%d: YES\n",kk);
22            }else{
23                printf("Case #%d: NO\n",kk);
24            }
25            kk++;
26        }
27
28     return 0;
29 }

题目大意:

一个星星一年73天,一个星星一年137天。给你一个天数,问两者是不是恰好都是第一天。

思路解析:

这题思路并不难想,就是求对73*173=10001取余是不是为0。这道题的坑就在大数的计算上。大数的取余计算,直接套模板。

(P.S:= =好累啊 下午5个小时 感觉身体被掏空。更一道下午的题算了,睡了睡了233333。)

时间: 2024-08-11 04:09:19

CCPC网赛,HDU5832_ A water problem的相关文章

[CCPC]网赛部分比赛代码

来自HDOJ: 5833 ( Zhu and 772002 ) 1 /* 2 ━━━━━┒ギリギリ♂ eye! 3 ┓┏┓┏┓┃キリキリ♂ mind! 4 ┛┗┛┗┛┃\○/ 5 ┓┏┓┏┓┃ / 6 ┛┗┛┗┛┃ノ) 7 ┓┏┓┏┓┃ 8 ┛┗┛┗┛┃ 9 ┓┏┓┏┓┃ 10 ┛┗┛┗┛┃ 11 ┓┏┓┏┓┃ 12 ┛┗┛┗┛┃ 13 ┓┏┓┏┓┃ 14 ┃┃┃┃┃┃ 15 ┻┻┻┻┻┻ 16 */ 17 #include <algorithm> 18 #include <iostre

2016 CCPC 网络赛 B 高斯消元 C 树形dp(待补) G 状压dp+容斥(待补) H 计算几何

2016 CCPC 网络赛 A - A water problem 水题,但读题有个坑,输入数字长度很大.. B - Zhu and 772002 题意:给出n个数(给出的每个数的质因子最大不超过2000),选出多个数相乘得b.问有多少种选法让b 为完全平方数. tags:高斯消元,求异或方程组解的个数.   好题 每个数先素数分解开.  对于2000以内的每个素数p[i],这n个数有奇数个p[i]则系数为1,偶数个则系数为0,最后n个数的p[i]系数异或和都要为0才会使得最后的积为完全平方数.

hdu 5443 The Water Problem(长春网络赛——暴力)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5443 The Water Problem Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1084    Accepted Submission(s): 863 Problem Description In Land waterless

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

ACM学习历程—HDU 5023 A Corrupt Mayor&#39;s Performance Art(广州赛区网赛)(线段树)

Problem Description Corrupt governors always find ways to get dirty money. Paint something, then sell the worthless painting at a high price to someone who wants to bribe him/her on an auction, this seemed a safe way for mayor X to make money. Becaus

Water Problem

water problem 发布时间: 2015年10月10日 15:34   时间限制: 1000ms   内存限制: 256M 描述 题意很简单 给你N个数, Q个查询 每次查询给你一个区间[L, R] 你要找出 [L, R] 这个区间里面取模M后的最大值. 输入 第一行一个T,表示测试数据组数.第二行两个整数N, M (1<=N<=10^5, 1<=M<=10^9).第三行给你N个整数 整数范围在1到10^9之间.第四行给你一个整数Q. ( 1<=Q<=10^5)

hdu 4974 A simple water problem(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4974 Problem Description Dragon is watching competitions on TV. Every competition is held between two competitors, and surely Dragon's favorite. After each competition he will give a score of either 0 or

hdu6153 A Secret CCPC网络赛 51nod 1277 KMP

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=6153 题意: 给出两个字符串S1,S2,求S2的所有后缀在S1中出现的次数与其长度的乘积之和. 思路: CCPC网络赛题解: https://post.icpc-camp.org/d/714-ccpc-2017 http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1277   是一样的 将s1,s2翻转,转化为求前缀在s1中出

dutacm.club Water Problem(矩阵快速幂)

Water Problem Time Limit:3000/1000 MS (Java/Others)   Memory Limit:163840/131072 KB (Java/Others)Total Submissions:1228   Accepted:121 [Submit][Status][Discuss] Description 函数 f:Z+→Z .已知 f(1),f(2) 的值,且对于任意 x>1,有 f(x+1)=f(x)+f(x?1)+sin(πx2) . 求 f(n) 的