結果

問題 No.125 悪の花弁
ユーザー t98slidert98slider
提出日時 2022-06-14 07:06:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,070 bytes
コンパイル時間 749 ms
コンパイル使用メモリ 89,840 KB
最終ジャッジ日時 2024-04-09 22:16:44
合計ジャッジ時間 1,209 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:6:10: error: incomplete type 'std::ios' {aka 'std::basic_ios<char>'} used in nested name specifier
    6 |     ios::sync_with_stdio(false);
      |          ^~~~~~~~~~~~~~~
main.cpp:7:5: error: 'cin' was not declared in this scope
    7 |     cin.tie(0);
      |     ^~~
main.cpp:2:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    1 | #include<atcoder/all>
  +++ |+#include <iostream>
    2 | using namespace std;
main.cpp:39:5: error: 'cout' was not declared in this scope
   39 |     cout << ans.val() << '\n';
      |     ^~~~
main.cpp:39:5: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?

ソースコード

diff #

#include<atcoder/all>
using namespace std;
using mint = atcoder::modint1000000007;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K, Csum = 0, gcdv = 0;
    cin >> K;
    vector<int> C(K), y;
    for(auto &&v:C){
        cin >> v;
        gcdv = __gcd(gcdv, v);
        Csum += v;
    }
    vector<mint> fact(Csum + 1), inv(Csum + 1);
    fact[0] = 1;
    for(int i = 1; i <= Csum; i++)fact[i] = i * fact[i - 1];
    for(int i = 1; i * i <= gcdv; i++){
        if(gcdv % i == 0){
            y.push_back(i);
            if(gcdv / i != i)y.push_back(gcdv / i);
        }
    }
    sort(y.rbegin(), y.rend());
    vector<mint> calc(y.size());
    mint ans;
    for(int i = 0; i < y.size(); i++){
        int d = y[i];
        calc[i] = fact[Csum / d - 1];
        mint div = fact[C[0] / d - 1];
        for(int j = 1; j < K; j++)div *= fact[C[j] / d];
        calc[i] /= div;
        for(int j = 0; j < i; j++){
            if(y[j] % y[i] == 0)calc[i] -= calc[j];
        }
        ans += calc[i] / (C[0] / d);
    }
    cout << ans.val() << '\n';
}
0