1. 程式人生 > >HDU 5832 A water problem(取模~)—— 2016中國大學生程式設計競賽

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 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(0N), 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

Author UESTC
Source

題目大意:

就是給你一個大數,讓你判斷是不是 73137 的公倍數。

解題思路:

大數 其實這個題一分析一下,因為 73137 是素數,所以就是對 73137 取模,然後跑一個循

環就行了,坑的是 cin 會超時,然後 改成 scanf 還超時,等了一會兒又交一遍竟然過了,AC

了!!!

My Code

/**
2016 - 08 - 14 下午
Author: ITAK

Motto:

今日的我要超越昨日的我,明日的我要勝過今日的我,
以創作出更好的程式碼為目標,不斷地超越自己。
**/
#include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <vector> #include <queue> #include <algorithm> #include <set> using namespace std; typedef long long LL; typedef unsigned long long ULL; const int INF = 1e9+5; const int MAXN = 1e7+5; const int MOD = 10001; const double eps = 1e-7; const double PI = acos(-1); using namespace std; char str[MAXN]; int main() { int cas = 1; while(scanf("%s",str)!=-1) { int len = strlen(str); int sum = 0; for(int i=0; i<len; i++) { sum = sum*10; sum = (sum+str[i]-'0'); sum = sum%MOD; } if(sum == 0) printf("Case #%d: YES\n",cas++); else printf("Case #%d: NO\n",cas++); } return 0; }

相關推薦

HDU 5832 A water problem~—— 2016中國大學生程式設計競賽

傳送門 A water problemTime Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 60   

HDU 5832 A water problem

8.14日網路賽第1題 Description Two planets named Haha and Xixi in the universe and they were created w

HDU 5833 Zhu and 772002 2016中國大學生程式設計競賽

Zhu and 772002 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 71 Acc

HDU 5912 Fraction 【模擬】 (2016中國大學生程式設計競賽(長春))

Fraction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2    Accepted Subm

hdu 5443 The Water Problem長春網絡賽——暴力

targe int hdu align follow limit eight math ould 題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=5443 The Water Problem Time L

HDU5832 A water problem【大數除】

A water problem Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 5419 Accepted Submission(s): 1768 P

HDU - 1603 A Puzzling Problem Dance Link 精確覆蓋問題

題意: 給定幾個方塊,看是否能拼成4*4的形狀,這些方塊不能旋轉,翻轉,如果能拼成,輸出拼成後的圖形(任意一個)。 分析: 可以用dfs進行搜尋填圖,但是自我感覺dance link寫起來更為簡單。 但要注意存圖跟建圖,儲存舞蹈鏈每行對應得起點座標,以及長寬,對應得編號,便於輸出。還

HDU 1005 Number Sequence【迴圈節

Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 158149    Ac

P1832 A+B Problem再升級

using 輸出格式 algorithm 一行 題目 -a scanf 問題 mes P1832 A+B Problem(再升級) 題目背景 ·題目名稱是吸引你點進來的 ·實際上該題還是很水的 題目描述 ·1+1=? 顯然是2 ·a+b=? 1001回看不謝 ·哥德巴赫猜想

洛谷 P1581 A+B Problem升級版

就是 reg 一個 ack left void 輸出 思路 bad P1581 A+B Problem(升級版) 題目背景 小明這在寫作業,其中有一道A+B Problem ,他想啊想啊想,就是想不出來,於是就找到了會編程的你......

HDU 4249 A Famous Equation數位DP

data else if 代碼量 pro const sta clu ++ 鏈接 題目鏈接:點擊打開鏈接 思路:用d[i][a][b][c][is]表示當前到了第i

完全背包【p1832】A+B Problem再升級

spa 枚舉 iostream fin break oid getchar() true += Description 給定一個正整數n,求將其分解成若幹個素數之和的方案總數。 Input 一行:一個正整數n Output 一行:一個整數表示方案總數 素數之和 ? 背包

HDU】1016Prime Ring Problemdfs+素數

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 68225 &n

整數快速冪、矩陣快速冪及其應用

1 #include <cstdio> 2 #include <cstring> 3 typedef long long ll; 4 const int mod = 998244353; 5 struct Matrix { 6 ll x[2][2]; 7 };

mycat1.6.5分片

mycat one群:106088787。 說明:根據分片欄位取模。 一、conf/schema.xml檔案 <?xml version="1.0"?> <!DOCTYPE mycat:schema SYSTEM "schema.dtd"> <mycat

Codeforces Round #280 (Div. 2) D:二分+浮點數模型轉為整型模型 E:數學

比賽地址: http://codeforces.com/contest/492 官方題解: Codeforces Round #280 (Div. 2) Editorial By Wild_Hamster, 11 hours ago, translation

HDU 1097 A hard puzzle快速冪

Problem Description lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^b.everybody objects to this BT pro

java算術運算子:%

本質:a % b = a - a /b * b;        int num1 = 10 % 3;//10-(10/3)*3==>10-3*3==>1int num2 = -10 % 3;//-10-((-10)/3)*3==>-10-(-3)*3==&g

【洛谷 1601】A+B Problem高精

問題描述 高精度加法(無負數) 樣例輸入 1 1 樣例輸出 2 const maxn=100; var a,b:array[1..maxn] of longint; proce

hdu3364-高斯消元

列n個方程,表示每個燈會被哪些開關控制, 得到一個一個n*m的矩陣,最後一列為所要求的狀態 則對這個(n+1)*(m)的矩陣高斯消元,得到方案數,答案爆int #include <cstdio> #include <cmath> #inclu