結果

問題 No.6 使いものにならないハッシュ
ユーザー yogi_cgyogi_cg
提出日時 2020-03-27 19:55:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,573 bytes
コンパイル時間 1,532 ms
コンパイル使用メモリ 176,980 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-30 16:45:41
合計ジャッジ時間 3,400 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 5 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 3 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 4 ms
4,380 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 

#define int long long

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e10;
const int MOD = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int h(int n)
{
    int res = 0;
    while(n > 0)
    {
        res += n % 10;
        n /= 10;
    }
    if(res >= 10) return h(res);
    return res;
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    const int MAX = 200000;
    int K, N; cin >> K >> N;
    vb prime(MAX+1, true); prime[0] = prime[1] = false;
    for(int i = 2; i * i <= MAX; i++)
    {
        if(prime[i])
        {
            for(int j = 2*i; j <= MAX; j += i) prime[j] = false;
        }
    }

    vi table;
    for(int i = K; i <= N; i++) if(prime[i]) table.push_back(i);

    int len = 0, x = 0;
    int l = 0, r = 0;
    map<int, int> m;
    for(int l = 0; l < table.size(); l++)
    {
        while(r < N && m[h(table[r])] == 0)
        {
            m[h(table[r])]++;
            r++;
        }
        if(chmax(len, r-l)) x = table[l];
        m[h(table[l])]--;
    }
    cout << x << endl;
}
0