#include using namespace std; long mod = 0; 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 " < &v,vector &p,vector &before){ cout << "getConbination" << " n " << n << " r " << r << endl; int denomi = 0; vectortop,bottom; for(int i = 0;ir){ break; } } //cout << "ここまできてる。" << endl; //top.push_back(tmp); tmp = r; for(int j=0;jr){ break; } } //cout << "aaaa" << endl; sort(top.begin(),top.end()); sort(bottom.begin(),bottom.end()); //cout << "bbbb" << endl; for(int i = 0,j=0; i < bottom.size(); i++){ // cout << "i:"<bottom[i]){ //donothing //cout << "fff" << endl; }else{ while(top[j]!=bottom[i]){ //cout << "ggg" << endl; j++; if(j>=top.size()){ break; } } //cout << "hhh" << endl; top[j]=1; bottom[i]=1; j++; } } }else{ break; } } for(int i = 0; i < top.size();i++){ if(top[i]!=1){ v.push_back(top[i]); } } #if 1 for(int i = 0; i < v.size();i++){ cout << v[i] << " "; } cout << endl; #endif } int main(){ int n,m; cin >> n; cin >> m; //n=3;m=2; //cout << 251374071 << endl; //cout << "n " << n << " m " << m << endl; int numInkBottol = m; int numWanabePainted =n; long patterns = 1; vector primeNumbers; mod = (long)pow(10,9)+7; //素数をリスト化する。 for(int i = 2;i<=n;i++){ bool isPrime = true; for(int j = 2; j < i; j++){ if(i%j==0){ isPrime=false; } } if(isPrime){ primeNumbers.push_back(i); //cout << i << " "; } } vector conbinationFactorize1; vector conbinationFactorize2; if (numWanabePainted > numInkBottol) { patterns = getDublicatedPatterns(numWanabePainted,numInkBottol); cout << patterns << endl; int plusMinus = 1; conbinationFactorize2 = {1}; for(int i = 1;i < numInkBottol; i++){ long conbinationModulo = 1; if(plusMinus==1){ conbinationFactorize1.clear(); getConbination(numInkBottol,i,conbinationFactorize1,primeNumbers,conbinationFactorize2); for(int j = 0; j 0; i--){ patterns = patterns * i; patterns = patterns % mod; } } cout << patterns << endl; }