456

# 题目

## 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.

10001
0
333

Case #1: YES
Case #2: YES
Case #3: NO

# 题解

(数据貌似有前导 0 )

# 代码

/*
By:OhYee
Github:OhYee
Blog:http://www.oyohyee.com/
Email:oyohyee@oyohyee.com

かしこいかわいい？
エリ0隶�

*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <bitset>
#include <iomanip>
using namespace std;

const int maxn = 10000005;
int kase = 0;

/*
* 完全大数模板
* 输出cin>>a
* 输出a.print();
* 注意这个输入不能自动去掉前导0的，可以先读入到char数组，去掉前导0，再用构造函数。
*/
#define MAXN 9999
#define MAXSIZE 1010
#define DLEN 4
struct BigInter {
int a[maxn]; //可以控制大数的位数
int len;
BigInter() {
len = 1; memset(a,0,sizeof(a));
} //构造函数
BigInter(const char*); //将一个字符串类型的变量转化为大数
int operator % (const int &)const; //大数对一个int类型的变量进行取模运算
void print(); //输出大数
};
BigInter::BigInter(const char *s) //将一个字符串类型的变量转化为大数
{
int t,k,index,L,i;
memset(a,0,sizeof(a));
L = strlen(s);
len = L / DLEN;
if(L%DLEN)len++;
index = 0;
for(i = L - 1; i >= 0; i -= DLEN) {
t = 0;
k = i - DLEN + 1;
if(k < 0)k = 0;
for(int j = k; j <= i; j++)
t = t * 10 + s[j] - '0';
a[index++] = t;
}
}
int BigInter::operator % (const int &b)const //大数对一个 int类型的变量进行取模
{
int i,d = 0;
for(i = len - 1; i >= 0; i--)
d = ((d*(MAXN + 1)) % b + a[i]) % b;
return d;
}
void BigInter::print() //输出大数
{
int i;
printf("%d",a[len - 1]);
for(i = len - 2; i >= 0; i--)
printf("%04d",a[i]);
printf("\n");
}
int t,k,index,L,i;
memset(a,0,sizeof(a));
L = strlen(s);
len = L / DLEN;
if(L%DLEN)len++;
index = 0;
for(i = L - 1; i >= 0; i -= DLEN) {
t = 0;
k = i - DLEN + 1;
if(k < 0)k = 0;
for(int j = k; j <= i; j++)
t = t * 10 + s[j] - '0';
a[index++] = t;
}
}

BigInter ans;
char s[maxn];

bool Do() {
if(scanf("%s",s) == EOF)
return false;

printf("Case #%d: ",++kase);

int pos = 0;
int len = strlen(s);
for(int i = 0;i < len;i++) {
if(s[i] != '0') {
pos = i;
break;
}
}
for(int i = pos;i < len;i++)
s[i - pos] = s[i];
s[len - pos] = '\0';

if(ans % 73 == 0 && 0 == ans % 137)
printf("YES\n");
else
printf("NO\n");

return true;
}

int main() {
cin.tie(0);
cin.sync_with_stdio(false);
while(Do());
return 0;
}

• 点击查看/关闭被识别为广告的评论