HDU 5832 A water problem (大数取模)

本文介绍了一道关于两个虚构行星Haha和Xixi的周期同步问题,通过判断特定时间是否为两行星年份开始的第一天来解决。该问题源自一场程序设计竞赛,通过数学运算实现了高效解答。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A water problem

Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 496    Accepted Submission(s): 26

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
Recommend
wange2014   |   We have carefully selected several similar problems for you:  5842 5841 5840 5838 5837 

题解:如果这个数能%73=0和%137=0,就输出YES。否则NO

代码:
#pragma comment(linker, "/STACK:102400000,102400000")
//#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<cmath>
#include<queue>
#include<set>
#include <utility>
#include<stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define mst(a) memset(a, 0, sizeof(a))
#define M_P(x,y) make_pair(x,y)  
#define rep(i,j,k) for (int i = j; i <= k; i++)  
#define per(i,j,k) for (int i = j; i >= k; i--)  
#define lson x << 1, l, mid  
#define rson x << 1 | 1, mid + 1, r  
const int lowbit(int x) { return x&-x; }  
const double eps = 1e-8;  
const int INF = 1e9+7; 
const ll inf =(1LL<<62) ;
const int MOD = 1e9 + 7;  
const ll mod = (1LL<<32);
const int N = 1010;
const int M=100010; 
template <class T1, class T2>inline void getmax(T1 &a, T2 b) {if(b>a)a = b;}  
template <class T1, class T2>inline void getmin(T1 &a, T2 b) {if(b<a)a = b;}
int read()
{
	int v = 0, f = 1;
	char c =getchar();
	while( c < 48 || 57 < c ){
		if(c=='-') f = -1;
		c = getchar();
	}
	while(48 <= c && c <= 57) 
		v = v*10+c-48, c = getchar();
	return v*f;
}
char s[10000100];
int main() 
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    #endif
	int cas = 1;
	while(gets(s)){
		int num = 0;
		for(int i=0; i<strlen(s); i++)
		{
			num=(num *10 + s[i]-'0') %10001;
		}
		if(num==0) printf("Case #%d: YES\n",cas++);
		else printf("Case #%d: NO\n",cas++);
	}
	return 0; 
}


 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值