1. 程式人生 > >HDU 5832 A water problem

HDU 5832 A water problem

8.14日網路賽第1題

Description

Two planets named Haha and Xixi in the universe and they were created with the universe beginning. 

There is  days in Xixi a year and  days in Haha a year. 

Now you know the days  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  huge test cases). 

For each test, we have a line with an only integer , the length of  is up to .

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

直接一位一位地算

我們隊伍的程式碼:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#define N 10000001
char str[N];
int len;
int i;
int mod;
long long ans;
int ca;
int main()
{
    mod = 10001;
    while(scanf("%s", str) != EOF)
    {
        ca++;
        ans = 0;
        len = strlen(str);
        for
(i = 0; i < len; i++)ans = (ans * 10 + str[i]-'0') % mod; if(ans == 0) printf("Case #%d: YES\n", ca); else printf("Case #%d: NO\n", ca); } return 0; }

雖然很慢,但是AC了

相關推薦

HDU 5832 A water problem

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

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 1402 A * B Problem Plus FFT

contain linker pri span stack pragma mod exce problem A * B Problem Plus Problem Description Calculate A * B. Input Each line

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

HDU 1402 A * B Problem Plus ——(大數乘法,FFT)

兩個 ret 處理 complex truct std spa strlen mes   因為剛學fft,想拿這題練練手,結果WA了個爽= =。   總結幾點犯的錯誤:   1.要註意處理前導零的問題。   2.一定要註意數組大小的問題。(前一個fft的題因為沒用到b數組,

HDU 6182 A Math Problem 水題

std 水題 div 輸出 iterator code php else fin   題目鏈接: http://acm.hdu.edu.cn/showproblem.php?pid=6182   題目描述: 輸入N, 輸出滿足k^k <= N 的 k的個數   解題思

hdu 1000 A + B Problem

esc urn rip end ostream accep others cstring line A + B Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja

hdu 4267 A Simple Problem with Integers

pre pri ets using type main return ger 如果 題意:給出一個長為n的序列,然後有q個操作,有兩種操作方式   1.輸入a,b,k,c,表示將區間[a,b]中的數i滿足(i-a)%k == 0加上c.   2.輸入一個數y,輸出序列中第

HDU-1000 A + B Problem

amp ostream case ace sam script pre code blog 題目 Problem Description Calculate A + B. Input Each line will contain two integers A and

【數論】2016中國大學生程序設計競賽 - 網絡選拔賽 A. A water problem (大整數取模)

判斷 eight ron lin 大學生 con while php bubuko 鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=5832 題意:兩個星球,一個星球一年只有137天,一個星球一年只有73天 輸入N(爆炸後第N

題解報告:hdu 1002 A + B Problem II(大數加法)

return 大數類 class family HERE contains urn integer ons Problem Description I have a very simple problem for you. Given two integers A and

HDU - 1402 A * B Problem Plus FFT裸題

swa complex asn 直線 lse () strlen mod -i http://acm.hdu.edu.cn/showproblem.php?pid=1402 題意:   求$a*b$ 但是$a$和$b$的範圍可以達到 $1e50000$ 題解:   顯然..

HDU 1402 A * B Problem Plus ( FFT )

amp hid sin 兩個 close 形式 hide utc closed 題意 : 求兩個大數相乘的結果 分析 : 可以將數拆成多項式的形式 例如 12345 (1 * x^4) + (2 * x^3) + (3 * x^2) + (4 * x^1) + (5 *

HDU-2101 A + B Problem Too(語法練習題)

A + B Problem Too Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 20917 Accepted Submissio

HDU - 2101 A + B Problem Too【水題】

A + B Problem Too Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 21290 Accepted Submissio

HDU 1002 A + B Problem II

A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 439087

HDU-1000——A+B problem

A+B problem Calculate A + B. Input Each line will contain two integers A and B. Process to end of file. Output For eac

hdu刷題之路——hdu 1000 A + B Problem

hdu刷題之路 hdu 1000 A + B Problem (水題入門) Problem Description Calculate A + B. Input Each line will contain two integers A and B. Process to end

HDU 5443 The Water Problem【RMQ水題】

題意:給出N個數和Q次查詢,沒次查詢L,R,輸出【L,R】內陣列元素的最大值; AC程式碼: #include<cstdio> #include<algorithm> u

HDU 1002 ( A + B Problem II )

A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To