結果

問題 No.1035 Color Box
ユーザー simojisimoji
提出日時 2020-04-26 20:35:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,831 bytes
コンパイル時間 1,533 ms
コンパイル使用メモリ 166,596 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 07:01:38
合計ジャッジ時間 4,208 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 RE -
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 2 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 2 ms
5,376 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
long mod = 0;
long getDublicatedPatterns(int cubes, int colors);
inline long getCombination(int all, int select);
int main(){
    int n,m;
    cin >> n;
    cin >> m;
    //cout << "n " << n << " m " << m << endl;
    int numInkBottol = m;
    int numWanabePainted =n;
    long patterns = 1;
    mod = (long)pow(10,9)+7;
    if (numWanabePainted > numInkBottol) {

        patterns = getDublicatedPatterns(numWanabePainted,numInkBottol);
        cout << patterns << endl;
        int plusMinus = 1;
        for(int i = numInkBottol;i > 0; i--){
            patterns = patterns - (plusMinus * getCombination(numInkBottol,i -1) * getDublicatedPatterns(numWanabePainted,i-1));
            patterns = patterns % mod;
            plusMinus *= -1;
            cout << patterns << endl;
        }

    }else{
        //インクの種類が十分多い
        //順番にインクのバケツにいれる。
        for (int i = numInkBottol; i > 0; i--){
            patterns = patterns * i;
            patterns = patterns % mod;
        }
    }
    cout << patterns << endl;
}
inline long getDublicatedPatterns(int cubes, int colors){
    long ret = 1;
    for(int i = cubes;i>0;i--){
        ret = ret*colors;
        ret = ret % mod;
        //cout << "i " << i << " colors " <<colors << " ret " << ret << endl;
    }
    //cout << "colors " <<colors << " ret " << ret << endl;
    return ret;
}
inline long getCombination(int all, int select){
    long ret = 1;
    long top = 1;
    long bottom = 1;
    //cout << "all " << all << " select " << select << endl;
    for (int i = 0; i < select; i++){
        top *= all-i;
        bottom *= select-i;
    }
    ret = top / bottom;
    //cout << "combination " << ret  << " top " << top << " bottom " << bottom << endl;
    return ret;
}
0