結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-11-05 21:54:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,541 bytes
コンパイル時間 1,844 ms
コンパイル使用メモリ 197,072 KB
実行使用メモリ 16,128 KB
最終ジャッジ日時 2024-04-24 05:41:00
合計ジャッジ時間 4,629 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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(" ");
        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(vdp[i] , vdp[i-1]);
    }

    pline(rdp);

}

/*

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

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

これは、maxA log maxA

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

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

*/
0