結果
| 問題 | 
                            No.391 CODING WAR
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Tawara
                         | 
                    
| 提出日時 | 2015-12-29 02:29:34 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 20 ms / 2,000 ms | 
| コード長 | 573 bytes | 
| コンパイル時間 | 139 ms | 
| コンパイル使用メモリ | 24,064 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-12 23:15:23 | 
| 合計ジャッジ時間 | 1,282 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 16 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         scanf("%lld %lld",&N,&M);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include <stdio.h>
typedef long long LL;
#define range(i,a,b) for(int i=(a); i < (b); i++)
#define rep(i,n) range(i,0,n)
#define U 200000
#define P 1000000007
LL mypow(LL b,LL e){
	LL ret = 1;
	for (;e>0;e>>=1){
		if(e&1) ret = ret * b % P;
		b = b * b % P;
	}
	return ret;
}
LL F[U+1],FI[U+1];
int main(){
	LL N,M,ans=0;
	scanf("%lld %lld",&N,&M);
	F[0] = 1;
	rep(i,M) F[i+1] = (i+1)*F[i]%P;
	FI[M] = mypow(F[M],P-2);
	rep(i,M) FI[M-1-i] = (M-i)*FI[M-i]%P;
	rep(k,M) ans = (ans+(k%2?-1:1)*(F[M]*FI[k]%P*FI[M-k]%P)*mypow(M-k,N)+P)%P;
	printf("%lld\n",ans);
	return 0;
}
            
            
            
        
            
Tawara