結果

問題 No.6 使いものにならないハッシュ
ユーザー BantakoBantako
提出日時 2017-08-17 21:10:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 891 bytes
コンパイル時間 1,348 ms
コンパイル使用メモリ 163,800 KB
実行使用メモリ 4,620 KB
最終ジャッジ日時 2023-10-14 23:07:50
合計ジャッジ時間 2,546 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,348 KB
testcase_01 AC 3 ms
4,352 KB
testcase_02 AC 5 ms
4,360 KB
testcase_03 AC 3 ms
4,352 KB
testcase_04 AC 3 ms
4,356 KB
testcase_05 AC 3 ms
4,352 KB
testcase_06 AC 4 ms
4,352 KB
testcase_07 AC 4 ms
4,460 KB
testcase_08 AC 4 ms
4,572 KB
testcase_09 AC 3 ms
4,352 KB
testcase_10 AC 3 ms
4,352 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 5 ms
4,404 KB
testcase_13 AC 3 ms
4,356 KB
testcase_14 AC 3 ms
4,412 KB
testcase_15 AC 4 ms
4,540 KB
testcase_16 AC 3 ms
4,416 KB
testcase_17 AC 4 ms
4,352 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 4 ms
4,352 KB
testcase_20 AC 3 ms
4,356 KB
testcase_21 AC 3 ms
4,348 KB
testcase_22 AC 4 ms
4,352 KB
testcase_23 AC 4 ms
4,352 KB
testcase_24 AC 4 ms
4,352 KB
testcase_25 AC 3 ms
4,484 KB
testcase_26 AC 5 ms
4,620 KB
testcase_27 AC 4 ms
4,348 KB
testcase_28 AC 4 ms
4,352 KB
testcase_29 AC 4 ms
4,352 KB
testcase_30 AC 4 ms
4,348 KB
testcase_31 AC 4 ms
4,352 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main(){
      | ^~~~
main.cpp: 関数 ‘int main()’ 内:
main.cpp:37:13: 警告: ‘maxn’ may be used uninitialized [-Wmaybe-uninitialized]
   37 |     cout << maxn << endl;
      |             ^~~~
main.cpp:17:22: 備考: ‘maxn’ はここで定義されています
   17 |     int K,N,maxi = 1,maxn;
      |                      ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
bool prime[200001];
int root[200001];
main(){
    for(int i = 2;i*i <= 200000;i++){
        if(prime[i])continue;
        for(int j = i*2;j <= 200000;j+=i)prime[j] = 1;
    }
    for(int i = 1;i <= 200000;i++){
        if(prime[i])root[i] = -1;
        else root[i] = i % 9;
    }
    int K,N,maxi = 1,maxn;
    cin >> K >> N;
    for(int i = max(2,K);i <= N;i++){
        if(prime[i])continue;
        int cnt = 1;
        bool used[10] = {};
        used[root[i]] = 1;
        for(int j = i+1;j <= N;j++){
            if(prime[j])continue;
            if(used[root[j]])break;
            else{
                used[root[j]] = 1;
                cnt++;
            }
        }
        if(maxi <= cnt){
            maxi = cnt;
            maxn = i;
        }
    }
    cout << maxn << endl;
}
0