結果

問題 No.1738 What's in the box?
ユーザー ぷら
提出日時 2021-11-12 21:41:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 502 bytes
コンパイル時間 2,275 ms
コンパイル使用メモリ 194,852 KB
最終ジャッジ日時 2025-01-25 16:08:50
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 68 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long gcd(long long a,long long b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return gcd(b,a % b);
    }
}

int main() {
    int N,M;
    cin >> N >> M;
    long long sum = 0;
    vector<int>W(N);
    for(int i = 0; i < N; i++) {
        cin >> W[i];
        sum += W[i];
    }
    long long g = gcd(sum,M);
    sum /= g;
    M /= g;
    for(int i = 0; i < N; i++) {
        cout << W[i]/sum*M << ((i+1 == N)?"\n":" ");
    }
}
0