結果
| 問題 |
No.42 貯金箱の溜息
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-11-21 23:21:42 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 5,000 ms |
| コード長 | 621 bytes |
| コンパイル時間 | 140 ms |
| コンパイル使用メモリ | 24,064 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 14:35:18 |
| 合計ジャッジ時間 | 1,008 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | for(scanf("%d",&T);T--;){
| ~~~~~^~~~~~~~~
main.cpp:20:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%lld",&m);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <stdio.h>
#define M 3000
#define MOD 1000000009
long long pow_binary_mod(long long x,long long y,long long mod){
long long z=1;
for(;y;y>>=1){
if((y&1)!=0)z=z*x%mod;
x=x*x%mod;
}
return z;
}
int Z[6]={1,5,10,50,100,500};
int A[M+1];
int main(){
A[0]=1;
for(int z=0;z<6;z++)for(int i=0;i<=M-Z[z];i++)A[i+Z[z]]+=A[i];
int T;
for(scanf("%d",&T);T--;){
long long m,x,r,s=0;
scanf("%lld",&m);
x=m/500,r=m%500;
for(int k=0;k<6;k++){
long long p=A[k*500+r];
for(int l=0;l<6;l++)if(l!=k)p=(x-l+MOD)%MOD*p%MOD*pow_binary_mod(k-l+MOD,MOD-2,MOD)%MOD;
s=(s+p)%MOD;
}
printf("%lld\n",s);
}
}