結果

問題 No.1723 [Cherry 3rd Tune *] Dead on
ユーザー mnmmnm
提出日時 2022-06-11 23:27:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,710 bytes
コンパイル時間 873 ms
コンパイル使用メモリ 81,984 KB
実行使用メモリ 7,772 KB
最終ジャッジ日時 2023-10-23 14:57:13
合計ジャッジ時間 5,800 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 5 ms
4,348 KB
testcase_04 AC 127 ms
4,348 KB
testcase_05 AC 38 ms
4,348 KB
testcase_06 WA -
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
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 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:69:16: warning: 'n_x' may be used uninitialized [-Wmaybe-uninitialized]
   69 |         if((n_x*a)<(n_y*b)){
      |            ~~~~^~~
main.cpp:59:14: note: 'n_x' was declared here
   59 |         lint n_x, p_x=0, n_y, p_y;
      |              ^~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <bitset>

#define rep(i,n) for(i=0; i<n; ++i)
#define in(a) cin >> a
#define out(a,b) cout << a << b
using namespace std;
using lint = long long;

bool is_prime(lint n){
    if(n==2||n==3)    return true;
    if(n<2||n%2==0) return false;
    bool f=true;
    for(lint i=3; i*i<=n; i+=2){
        if(n%i==0){
            f=false; break;
        }
    }
    return f;
}

vector<pair<lint, lint>> prime_factorize(int n){
    vector<pair<lint, lint>> prime_factors; lint p=2, cnt=0;
    while(n>1){
        if(n%p!=0){
            if(cnt!=0){
                prime_factors.push_back(make_pair(p, cnt)); cnt=0;
            }
            do{p++;}while(!is_prime(p));
        }
        else{
            n/=p; cnt++;
        }
    }
    prime_factors.push_back(make_pair(p, cnt));
    return prime_factors;
}

int main(void){
    // lint i, j;
    lint n, m;
    lint x, a, y, b;
    in(x);
    in(a);
    in(y);
    in(b);
    vector<pair<lint, lint>> primes_x=prime_factorize(x);
    vector<pair<lint, lint>> primes_y=prime_factorize(y);
    lint x_i=primes_x.size(), y_i=primes_y.size();
    bool covered=true;
    
    lint i, j=0;
    rep(i,y_i){
        lint n_x, p_x=0, n_y, p_y;
        tie(p_y, n_y)=primes_y[i];
        while(p_x!=p_y){
            if(j>x_i-1){
                covered=false;
                break;
            }
            tie(p_x, n_x)=primes_x[j];
            j++;
        }
        if((n_x*a)<(n_y*b)){
            covered=false;
            break;
        }
        if(!covered)    break;
    }
    
    covered? out("Yes", endl):out("No", endl);
    return 0;
}
0