結果

問題 No.1330 Multiply or Divide
ユーザー MtSakaMtSaka
提出日時 2021-01-08 22:22:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 749 bytes
コンパイル時間 1,674 ms
コンパイル使用メモリ 172,980 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-28 03:41:29
合計ジャッジ時間 7,203 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 41 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 110 ms
5,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 AC 103 ms
5,376 KB
testcase_19 AC 103 ms
5,376 KB
testcase_20 AC 103 ms
5,376 KB
testcase_21 AC 104 ms
5,376 KB
testcase_22 AC 104 ms
5,376 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

//GIVE ME AC!!!!!!!!!!!!!!!!!
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
   int n,m,p;
   cin>>n>>m>>p;
    vector<pair<int,int>>a(n);
    int one=0;
    rep(i,n){
        int b;
        cin>>b;
        int sum=0;
        while(b%p==0){
            b/=p;
           sum++;
        }
        if(b==1){
            one++;
        }
        a[i]=make_pair(b,sum);
    }
    sort(a.begin(),a.end());
    int ans=0;
    int start=1;
    if(one==n){
        cout<<-1<<endl;
    }
    else{
        while(start<=m){
           int aa=a[n-1].second;
            ans+=1+aa;
            start*=a[n-1].first;
        }
       cout<<ans<<endl;
    }
}
        
    
0