多数の問題点は、擬似精度を法

トレーニング1 - Eのタイトル

2つの惑星は、宇宙の母と西渓と名付けられ、それらは宇宙の始まりで作成されました。

西渓で7373日年と母で137137日年があります。

今、あなたは日にビッグバン後のNNを知って、あなたはそれが2つの惑星についての年の最初の日であるかどうかを答える必要があります。

入力

(55巨大なテストケースについての)いくつかのテストケースがあります。

各試験のために、我々は唯一のN(0≦)N(0≦)の整数の行を有し、NNの長さは、最大1000000010000000です。

出力

答えのために、出力「YES」か「NO」:i番目のテストケース、出力ケース#iのため。

サンプル入力

10001
0
333

サンプル出力
ケース#1:YES
ケース#2:YES
ケース#3:NO

#pragma warning (disable:4996)
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <queue>
#define inf 0X7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1e7 + 5;
const int M = 9;//状压

char str[maxn];

int main()
{
	int cas = 0;
	while (scanf("%s", str) != EOF)
	{
	int tmp = 0;//不会超1e6
	for (int i = 0; i < strlen(str); i++)
		tmp = (tmp * 10 + str[i] - '0') % 10001;
	if (tmp == 0)
		printf("Case #%d: YES\n", ++cas);
	else
		printf("Case #%d: NO\n", ++cas);
	}
	return 0;
}

アイデアは:
、入力xの数を設定した場合に満足のx%73 == 0 && X% 137 == 0、 73と73の最小公倍数は137 * 137 = 10001であるため、条件は、x%10001 == 0、答えははい出力、出力反していません。
'0' [i]を、X =Σi番目のビットの数を示す-多数の操作が使用STR [I]とすることができるモジュロ A [I] * 10 ^(I-1)、 及び(+ bのため)%M == A%M + %のM B、 Xモジュロの結果を蓄積する[I]モジュロ結果であり得ます。

公開された28元の記事 ウォンの賞賛0 ビュー342

おすすめ

転載: blog.csdn.net/xukeke12138/article/details/104530600