結果

問題 No.1257 変わった平均値
ユーザー tokusakurai
提出日時 2020-10-16 23:35:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,816 bytes
コンパイル時間 1,999 ms
コンパイル使用メモリ 197,124 KB
最終ジャッジ日時 2025-01-15 09:50:35
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int a[3], b[3];
    rep(i, 3) cin >> a[i];
    rep(i, 3) cin >> b[i];
    if(a[0] == b[0] && a[1] == b[1] && a[2] == b[2]) {cout << "Yes" << endl << 2 << endl; return 0;}

    vector<int> v(3);
    iota(all(v), 0);
    bool first = true;
    do{
        int c[3];
        rep(i, 3){
            if(a[i]%b[v[i]] != 0) c[i] = -1;
            else c[i] = __builtin_ctz(a[i]/b[v[i]]);
        }
        if(c[0] == -1 || c[1] == -1 || c[2] == -1) ;
        elif((c[0]+c[1]+c[2])%2 == 1) ;
        elif(c[0] > c[1]+c[2] || c[1] > c[2]+c[0] || c[2] > c[0]+c[1]) ;
        else{
            cout << "Yes" << endl;
            rep(i, c[1]+c[2]-c[0]) cout << 'A' << ' ';
            rep(i, c[2]+c[0]-c[1]) cout << 'B' << ' ';
            rep(i, c[0]+c[1]-c[2]) cout << 'C' << ' ';
            if(!first) cout << 2 << ' ';
            cout << endl;
            return 0;
        }
        first = false;
    } while(next_permutation(all(v)));
    cout << "No" << endl;
}
0