結果
問題 | No.1035 Color Box |
ユーザー | simoji |
提出日時 | 2020-04-27 18:30:22 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,704 bytes |
コンパイル時間 | 1,735 ms |
コンパイル使用メモリ | 170,288 KB |
実行使用メモリ | 13,644 KB |
最終ジャッジ日時 | 2024-11-22 02:32:50 |
合計ジャッジ時間 | 23,587 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
10,496 KB |
testcase_01 | RE | - |
testcase_02 | WA | - |
testcase_03 | AC | 2 ms
9,428 KB |
testcase_04 | TLE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | TLE | - |
testcase_09 | TLE | - |
testcase_10 | AC | 7 ms
9,428 KB |
testcase_11 | AC | 3 ms
5,248 KB |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | AC | 2 ms
5,248 KB |
testcase_17 | AC | 2 ms
5,248 KB |
testcase_18 | AC | 2 ms
5,248 KB |
testcase_19 | AC | 3 ms
5,248 KB |
testcase_20 | AC | 2 ms
5,248 KB |
testcase_21 | AC | 2 ms
5,248 KB |
testcase_22 | AC | 2 ms
5,248 KB |
testcase_23 | AC | 2 ms
5,248 KB |
testcase_24 | AC | 2 ms
5,248 KB |
testcase_25 | AC | 2 ms
5,248 KB |
testcase_26 | AC | 2 ms
5,248 KB |
testcase_27 | AC | 2 ms
5,248 KB |
testcase_28 | AC | 2 ms
5,248 KB |
testcase_29 | AC | 2 ms
5,248 KB |
testcase_30 | AC | 2 ms
5,248 KB |
testcase_31 | AC | 2 ms
5,248 KB |
testcase_32 | AC | 2 ms
5,248 KB |
testcase_33 | AC | 2 ms
5,248 KB |
testcase_34 | AC | 1 ms
5,248 KB |
testcase_35 | AC | 2 ms
5,248 KB |
testcase_36 | AC | 2 ms
5,248 KB |
testcase_37 | AC | 2 ms
10,496 KB |
ソースコード
#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; //s << "n " << n << " m " << m << endl; int numInkBottol = m; int numWanabePainted =n; long patterns = 1; mod = (long)pow(10,9)+7; //long tmp = getCombination(45,43); //cout << tmp << endl; //return 0; 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; } if(patterns < 0){ patterns = mod + patterns; } }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; vector <int> top; vector <int> bottom; for(int i = select;i > 0; i--){ top.push_back(all-(select-i)); bottom.push_back(i); } for(int i = 0; i < select;i++){ //cout << " " << top[i]; } //cout << endl; for(int i = 0; i < select;i++){ //cout << " " << bottom[i]; } //cout << endl; for(int i = 0; i< select;i++){ if(bottom[i]!=1){ for(int j =0 ; j < select; j++){ if(top[j]%bottom[i]==0){ top[j] = (top[j]/bottom[i]); bottom[i] = 1; } } } } long topTmp = 1; long bottomTmp = 1; for(int i = 0; i < select;i++){ //cout << " " << top[i]; topTmp*=top[i]; bottomTmp*=bottom[i]; } //cout << endl; for(int i = 0; i < select;i++){ //cout << " " << bottom[i]; } ret = topTmp/bottomTmp; //cout << "conbination " << ret << " all " << all << " select " << select<< endl; return ret; }