結果

問題 No.6 使いものにならないハッシュ
ユーザー kotatsugamekotatsugame
提出日時 2019-10-14 02:25:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 577 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 69,828 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-14 23:18:31
合計ジャッジ時間 1,702 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 3 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 1 ms
4,352 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 3 ms
4,372 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 3 ms
4,356 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 2 ms
4,352 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 3 ms
4,356 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 AC 2 ms
4,352 KB
testcase_25 AC 2 ms
4,352 KB
testcase_26 AC 3 ms
4,348 KB
testcase_27 AC 2 ms
4,352 KB
testcase_28 AC 2 ms
4,352 KB
testcase_29 AC 3 ms
4,348 KB
testcase_30 AC 3 ms
4,348 KB
testcase_31 AC 3 ms
4,352 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:14:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   14 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
bool isp[200001];
vector<int>A;
int h(int X)
{
	if(X<10)return X;
	int s=0;
	while(X)s+=X%10,X/=10;
	return h(s);
}
int cnt[10];
main()
{
	int K,N;
	cin>>K>>N;
	for(int i=2;i<=N;i++)isp[i]=true;
	for(int i=2;i<=N;i++)
	{
		if(isp[i])
		{
			if(i>=K)A.push_back(i);
			for(int j=i+i;j<=N;j+=i)isp[j]=false;
		}
	}
	int ans=-1,len=-1,L=0;
	for(int R=0;R<A.size();R++)
	{
		int r=h(A[R]);
		while(cnt[r]>0)
		{
			cnt[h(A[L++])]--;
		}
		cnt[r]++;
		if(len<=R-L+1)
		{
			len=R-L+1;
			ans=A[L];
		}
	}
	cout<<ans<<endl;
}
0