結果
| 問題 |
No.6 使いものにならないハッシュ
|
| コンテスト | |
| ユーザー |
newlife171128
|
| 提出日時 | 2018-02-12 12:40:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,634 bytes |
| コンパイル時間 | 1,785 ms |
| コンパイル使用メモリ | 160,440 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-24 04:51:38 |
| 合計ジャッジ時間 | 2,169 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 32 |
ソースコード
#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;
}
newlife171128