結果

問題 No.6 使いものにならないハッシュ
ユーザー BantakoBantako
提出日時 2017-08-17 21:03:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 887 bytes
コンパイル時間 1,637 ms
コンパイル使用メモリ 163,852 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-22 14:52:33
合計ジャッジ時間 2,796 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 3 ms
5,376 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 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main(){
      | ^~~~
main.cpp: In function 'int main()':
main.cpp:37:13: warning: 'maxn' may be used uninitialized [-Wmaybe-uninitialized]
   37 |     cout << maxn << endl;
      |             ^~~~
main.cpp:17:22: note: 'maxn' was declared here
   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 < 100;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