結果

問題 No.917 Make One With GCD
ユーザー chocoruskchocorusk
提出日時 2019-10-25 21:39:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,367 bytes
コンパイル時間 3,976 ms
コンパイル使用メモリ 123,164 KB
実行使用メモリ 5,088 KB
最終ジャッジ日時 2023-09-30 07:13:06
合計ジャッジ時間 2,907 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 14 ms
5,088 KB
testcase_07 AC 9 ms
4,392 KB
testcase_08 AC 4 ms
4,376 KB
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 AC 2 ms
4,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 1 ms
4,376 KB
testcase_30 WA -
testcase_31 AC 2 ms
4,380 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n; cin>>n;
    int a[55];
    vector<int> v;
    set<int> vd[55];
    for(int i=0; i<n; i++){
        cin>>a[i];
        for(int j=1; j*j<=a[i]; j++){
            if(a[i]%j==0){
                vd[i].insert(j);
                v.push_back(j);
                if(j*j<a[i]){
                    vd[i].insert(a[i]/j);
                    v.push_back(a[i]/j);
                }
            }
        }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    int m=v.size();
    vector<ll> cnt(m);
    for(int i=m-1; i>=0; i--){
        int c=0;
        for(int j=0; j<n; j++){
            if(vd[j].find(v[i])!=vd[j].end()) c++;
        }
        cnt[i]=1ll<<c;
        for(int j=i+1; j<m; j++){
            if(v[j]%v[i]==0) cnt[i]-=cnt[j];
        }
    }
    cout<<cnt[0]<<endl;
    return 0;
}
0