結果
| 問題 |
No.391 CODING WAR
|
| コンテスト | |
| ユーザー |
hashiryo
|
| 提出日時 | 2018-04-25 14:51:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,114 bytes |
| コンパイル時間 | 592 ms |
| コンパイル使用メモリ | 60,132 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-27 21:02:35 |
| 合計ジャッジ時間 | 1,852 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 5 WA * 11 |
ソースコード
//
// main.cpp
// ProCon
//
// Created by hashimotoryoma on 2017/08/20.
// Copyright © 2017年 hashimotoryoma. All rights reserved.
//
#include <iostream>
//#include <fstream>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
ll mod_pow(ll a,ll r){
if(r==0)
return 1;
//cout << a << " " << r <<endl;
ll res=mod_pow(a*a%MOD,r/2);
if(r&1){
res=res*a%MOD;
}
return res;
}
ll mod_inv(ll a){
//cout <<"inv "<< a << endl;
return mod_pow(a,MOD-2);
}
ll N,M;
ll ans;
int main() {
// insert code here... return 0;
//////
// input from txt
/*
std::ifstream in("input.txt");
std::cin.rdbuf(in.rdbuf());
std::ofstream out("output.txt");
std::cout.rdbuf(out.rdbuf());
///////
*/
cin >> N >> M;
if(N<M){
cout << 0 << endl;
return 0;
}
ll e = 1;
ll C = 1;
for(int i=0;i<M;i++){
ans = (ans+e*C*mod_pow(M-i,N)+MOD)%MOD;
e *= -1;
C = C*(M-i)*mod_inv(i+1)%MOD;
}
cout << ans << endl;
return 0;
}
hashiryo