結果

問題 No.6 使いものにならないハッシュ
ユーザー ojisan_ITojisan_IT
提出日時 2017-08-11 09:18:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,516 bytes
コンパイル時間 1,802 ms
コンパイル使用メモリ 171,520 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 22:11:21
合計ジャッジ時間 3,315 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cout<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
  
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;

vi v;

int h(int a){
  if(a /10 == 0) return a;
  int now = 0;
  for(int i = 100000; i != 0; i/=10)
    now += a/i, a -= a/i * i;
  return h(now);
}

bool col(int l,int r){
  map<int,int> m;
  for(int i = l; i <= r && i < v.size(); i++){
    if(!m[v[i]])
      m[v[i]]++;
    else
      return true;
  }
  return false;
}

vi p;

int main(){
  int k,n; cin >> k >> n;
  for(int i = k; i <= n; i++){
    for(int j = 2; j*j <= i; j++){
      if(i%j==0)
        break;
      if((j+1)*(j+1) > i || i==2){
        v.pb(h(i));
        p.pb(i);
        break;
      }
    }
  }
  int ans = 0;
  int tans = 0;
  int num = 0;
  int l = 0,r = 0;
  while(r != v.size()){
    if(!col(l,r)){
      r++; tans++; if(tans >= ans) num = p[l];
      ans = max(ans,tans);
    }else{
      tans--;l++;
    }
  }
  cout << num << endl;
}
0