結果
| 問題 |
No.6 使いものにならないハッシュ
|
| コンテスト | |
| ユーザー |
Pulmn
|
| 提出日時 | 2018-07-24 23:24:44 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 5,000 ms |
| コード長 | 1,260 bytes |
| コンパイル時間 | 1,433 ms |
| コンパイル使用メモリ | 168,824 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-16 16:44:33 |
| 合計ジャッジ時間 | 2,475 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<27;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-18;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
const int M=200001;
int l,r,p[M];
int f(int x){
if(x<10) return x;
int t=0;
while(x) t+=x%10,x/=10;
return f(t);
}
int main(){
cin>>l>>r;
fill(p,p+M,1);
p[0]=p[1]=0;
for(int i=2;i<M;i++) if(p[i]){
for(int j=2*i;j<M;j+=i) p[j]=0;
}
vi a,b;
while(l<=r){
if(p[l]){
a.push_back(l);
b.push_back(f(l));
}
l++;
}
P p={0,0};
set<int> st;
int I=0,n=a.size();
for(int i=0;i<n;i++){
while(I<n){
if(st.find(b[I])==st.end()){
st.insert(b[I]);
I++;
}
else break;
}
p=max(p,{st.size(),a[i]});
st.erase(b[i]);
}
cout<<p.second<<endl;
}
Pulmn