結果

問題 No.6 使いものにならないハッシュ
ユーザー 0w10w1
提出日時 2016-11-21 21:14:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 665 bytes
コンパイル時間 1,739 ms
コンパイル使用メモリ 172,296 KB
実行使用メモリ 6,812 KB
最終ジャッジ日時 2024-05-05 12:18:24
合計ジャッジ時間 5,150 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 205 ms
5,376 KB
testcase_03 AC 16 ms
5,376 KB
testcase_04 AC 37 ms
5,376 KB
testcase_05 AC 33 ms
5,376 KB
testcase_06 AC 103 ms
5,376 KB
testcase_07 AC 60 ms
5,376 KB
testcase_08 AC 91 ms
5,376 KB
testcase_09 AC 39 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 15 ms
5,376 KB
testcase_12 AC 113 ms
5,376 KB
testcase_13 AC 23 ms
5,376 KB
testcase_14 AC 41 ms
5,376 KB
testcase_15 AC 93 ms
5,376 KB
testcase_16 AC 77 ms
5,376 KB
testcase_17 AC 162 ms
5,376 KB
testcase_18 AC 199 ms
5,376 KB
testcase_19 AC 155 ms
5,376 KB
testcase_20 AC 122 ms
5,376 KB
testcase_21 AC 8 ms
5,376 KB
testcase_22 AC 141 ms
5,376 KB
testcase_23 AC 117 ms
5,376 KB
testcase_24 AC 135 ms
5,376 KB
testcase_25 AC 76 ms
5,376 KB
testcase_26 AC 178 ms
5,376 KB
testcase_27 AC 126 ms
5,376 KB
testcase_28 AC 60 ms
5,376 KB
testcase_29 AC 178 ms
5,376 KB
testcase_30 AC 139 ms
5,376 KB
testcase_31 AC 133 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int get_hash( int v ){
  if( v < 10 )
    return v;
  int u = 0;
  while( v )
    u += v % 10, v /= 10;
  return get_hash( u );
}

signed main(){
  int L, R; cin >> L >> R;
  vector< int > cnt( 10 );
  deque< int > dq;
  int maxlen = 0, ans = -1;
  for( int i = R; i >= L; --i ){
    int ng = 0;
    for( int j = 2; j * j <= i; ++j )
      ng |= i % j == 0;
    if( ng ) continue;
    int hv = get_hash( i );
    while( cnt[ hv ] )
      --cnt[ dq.back() ], dq.pop_back();
    ++cnt[ hv ], dq.emplace_front( hv );
    if( maxlen < dq.size() )
      maxlen = dq.size(), ans = i;
  }
  cout << ans << endl;
  return 0;
}
0