結果

問題 No.6 使いものにならないハッシュ
ユーザー kyuridenamidakyuridenamida
提出日時 2016-02-10 19:05:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 553 bytes
コンパイル時間 1,275 ms
コンパイル使用メモリ 146,912 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-14 22:57:10
合計ジャッジ時間 3,020 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 27 ms
4,352 KB
testcase_03 AC 4 ms
4,348 KB
testcase_04 AC 6 ms
4,352 KB
testcase_05 AC 7 ms
4,348 KB
testcase_06 AC 14 ms
4,348 KB
testcase_07 AC 9 ms
4,348 KB
testcase_08 AC 13 ms
4,348 KB
testcase_09 AC 6 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 16 ms
4,348 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 6 ms
4,348 KB
testcase_15 AC 14 ms
4,352 KB
testcase_16 AC 11 ms
4,348 KB
testcase_17 AC 21 ms
4,348 KB
testcase_18 AC 26 ms
4,352 KB
testcase_19 AC 20 ms
4,352 KB
testcase_20 AC 17 ms
4,352 KB
testcase_21 AC 3 ms
4,352 KB
testcase_22 AC 19 ms
4,348 KB
testcase_23 AC 17 ms
4,348 KB
testcase_24 AC 18 ms
4,348 KB
testcase_25 AC 10 ms
4,352 KB
testcase_26 AC 22 ms
4,352 KB
testcase_27 AC 17 ms
4,348 KB
testcase_28 AC 10 ms
4,348 KB
testcase_29 AC 23 ms
4,348 KB
testcase_30 AC 20 ms
4,348 KB
testcase_31 AC 19 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 2分くらいかも
#include <bits/stdc++.h>
using namespace std;

int d(int n){
	if( n < 10 ) return n;
	return d(d(n/10)+n%10);
}

int main(){
	int A,B;
	cin >> A >> B;
	vector<int> p;
	for(int i = max(2,A) ; i <= B ; i++){
		int f = 1;
		for(int j = 2 ; j*j <= i ; j++)
			if( i % j == 0 ){ f = 0; break; }
		if(f) p.push_back(i);
	}
	pair<int,int> ans;
	for(int i = 0 ; i < p.size() ; i++){
		int c[10] = {};
		for(int j = i ; j < p.size() ; j++){
			if( c[d(p[j])]++ ) break;
			ans = max(ans,{j-i+1,p[i]});
		}
	}
	cout << ans.second << endl;
}
0