結果

問題 No.6 使いものにならないハッシュ
ユーザー newlife171128newlife171128
提出日時 2018-02-12 12:40:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,634 bytes
コンパイル時間 1,201 ms
コンパイル使用メモリ 146,548 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-15 20:16:21
合計ジャッジ時間 3,008 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include "bits/stdc++.h"
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <unordered_map>
#include <string.h>
#include <utility>

typedef long long ll;
const int INF = 1e8;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;

typedef pair<int, int> P;

bool prime[200001];

vector<int> prime_numbe;

bool check[10];

void check_inite() {
	for (int i = 0; i < 10; i++) {
		check[i] = false;
	}
}
void shieve(int x, int y) {
	for (int i = 2; i <= y; i++) {
		if (!prime[i]) {

			if (i >= x) {
				prime_numbe.push_back(i);
			}
			for (int j = i * 2; j <= y; j += i) {
				prime[j] = true;
			}
		}
	}
}

int has(int x) {
	int s = 0;

	while (x / 10 != 0) {
		s = x % 10;

		x /= 10;

		x += s;
	}

	return x;
}

int main() {

	int k, n;
	cin >> k >> n;

	shieve(k, n);

	/*	for (int i = 0; i < prime_numbe.size(); i++) {
	 cout << prime_numbe[i] << endl;
	 }*/
	int left = 0, right = 0;

	int ct = 0;

	int ans = 0;

	int tmp = 0;

	for (left = 0; left < prime_numbe.size(); left++) {

		for (right = left; right < prime_numbe.size(); right++) {

			int hashnum = has(prime_numbe[right]);

			if (!check[hashnum]) {
				ct++;
				check[hashnum] = true;

				/*cout << hashnum << " " << prime_numbe[right] << endl;*/

			} else {
				break;

			}

		}
		if (tmp <= ct) {
			ans = max(ans, prime_numbe[left]);

			cout << ans << endl;
			tmp = ct;
		}
		ct = 0;
		check_inite();
	}

	cout << ans << endl;

	return 0;
}

0