結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-11-05 21:56:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 1,542 bytes
コンパイル時間 2,204 ms
コンパイル使用メモリ 197,596 KB
実行使用メモリ 16,076 KB
最終ジャッジ日時 2024-04-25 17:21:30
合計ジャッジ時間 5,514 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,856 KB
testcase_01 AC 37 ms
11,232 KB
testcase_02 AC 35 ms
11,208 KB
testcase_03 AC 35 ms
11,124 KB
testcase_04 AC 34 ms
11,284 KB
testcase_05 AC 35 ms
11,296 KB
testcase_06 AC 35 ms
11,192 KB
testcase_07 AC 35 ms
11,276 KB
testcase_08 AC 36 ms
11,420 KB
testcase_09 AC 34 ms
11,200 KB
testcase_10 AC 38 ms
11,144 KB
testcase_11 AC 35 ms
11,200 KB
testcase_12 AC 35 ms
11,120 KB
testcase_13 AC 86 ms
16,036 KB
testcase_14 AC 86 ms
15,844 KB
testcase_15 AC 84 ms
15,788 KB
testcase_16 AC 85 ms
15,792 KB
testcase_17 AC 85 ms
15,868 KB
testcase_18 AC 82 ms
16,076 KB
testcase_19 AC 81 ms
15,848 KB
testcase_20 AC 80 ms
16,072 KB
testcase_21 AC 80 ms
15,792 KB
testcase_22 AC 84 ms
15,804 KB
testcase_23 AC 76 ms
15,844 KB
testcase_24 AC 75 ms
16,024 KB
testcase_25 AC 81 ms
15,848 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:22:20: warning: overflow in conversion from 'double' to 'll' {aka 'long long int'} changes value from '2.1e+19' to '9223372036854775807' [-Woverflow]
   22 | const ll INF = 1e18+2e19;
      |                ~~~~^~~~~

ソースコード

diff #

#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <list>

using namespace std;

#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll mod = 1000000007;
const ll inf = 1000000000;
const ll INF = 1e18+2e19;


void pline(vector<ll> lis){
    rep(i,0,lis.size()){
        printf ("%lld",lis[i]);
        if (i != lis.size()-1) printf("\n");
        else printf("\n");
    }
}

int main(){

    ll N;
    scanf ("%lld",&N);

    vector<ll> A(N);
    rep(i,0,N){
        scanf ("%lld",&A[i]);
    }

    vector<ll> vdp(1000001 , 0);
    for (ll a : A){
        vdp[a] += 1;
    }

    rep(i,1,1000001){
        for (ll j = 2*i ; j < 1000001 ; j+=i){
            vdp[i] += vdp[j];
        }
    }

    vector<ll> rdp(N , 0);
    rep(i,0,1000001){
        if (vdp[i] != 0) rdp[ N-vdp[i] ] = i;
    }

    rep(i,1,N){
        rdp[i] = max(rdp[i] , rdp[i-1]);
    }

    pline(rdp);

}

/*

消すのと同じ・・・
?個取った時のGCDの最大値を求める。

gcdを決め打った時、取れるのはgcdの倍数だけ
それぞれの数字に関して、gcdとした時いくつ取れるか?
を計算すればおk

これは、maxA log maxA

vdp[v] = gcdをvとした時、とれる個数の最大値

rdp[s] = s個取るとき、ありうるgcdの最大値
とすればおk

*/
0