結果
問題 | No.6 使いものにならないハッシュ |
ユーザー | 0w1 |
提出日時 | 2016-11-21 21:14:01 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 665 bytes |
コンパイル時間 | 1,701 ms |
コンパイル使用メモリ | 171,712 KB |
実行使用メモリ | 10,016 KB |
最終ジャッジ日時 | 2024-05-05 12:18:17 |
合計ジャッジ時間 | 14,086 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
ソースコード
#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; --L ){ 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; }