結果

問題 No.6 使いものにならないハッシュ
ユーザー sigma425sigma425
提出日時 2015-04-25 09:14:32
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 1,024 bytes
コンパイル時間 2,989 ms
コンパイル使用メモリ 149,352 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-14 22:51:04
合計ジャッジ時間 2,769 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
const ll ccc=200000;
bool prime[ccc+1];
vector<ll> pr;
void makeprime(){
	ll i,j;
	for(i=2;i<=ccc;i++) prime[i]=true;
	for(i=2;i*i<=ccc;i++) if(prime[i]) for(j=2;j*i<=ccc;j++) prime[j*i]=false;
	for(i=2;i<=ccc;i++) if(prime[i]) pr.push_back(i);
}
int cnt(int x){
	int s=0;
	while(x){
		s+=x%10;
		x/=10;
	}
	if(s<10) return s;
	return cnt(s);
}
int main(){
	makeprime();
	int a,b;
	cin>>a>>b;
	vector<int> ps,_;
	for(int p:pr) if(a<=p&&p<=b) ps.pb(cnt(p)),_.pb(p);
	int mx=0,id=0;
	rep(i,ps.size()){
		bool x[50]={};
		int e=0;
		for(int j=i;j<ps.size();j++,e++){
			if(x[ps[j]]) break;
			x[ps[j]]=1;
		}
		if(mx<=e){
			mx=e;
			id=_[i];
		}
	}
	cout<<id<<endl;
}
0