結果
| 問題 |
No.41 貯金箱の溜息(EASY)
|
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-06-22 16:00:59 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 959 bytes |
| コンパイル時間 | 616 ms |
| コンパイル使用メモリ | 30,464 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 09:20:19 |
| 合計ジャッジ時間 | 1,031 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 |
コンパイルメッセージ
main.c: In function 'in':
main.c:8:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
8 | #define gc() getchar_unlocked()
| ^~~~~~~~~~~~~~~~
main.c:16:27: note: in expansion of macro 'gc'
16 | ll n = 0; int c = gc();
| ^~
main.c: In function 'out':
main.c:9:15: warning: implicit declaration of function 'putchar_unlocked' [-Wimplicit-function-declaration]
9 | #define pc(c) putchar_unlocked(c)
| ^~~~~~~~~~~~~~~~
main.c:25:17: note: in expansion of macro 'pc'
25 | if (!n) pc('0');
| ^~
ソースコード
// yukicoder: No.41 貯金箱の溜息(EASY)
// 2019.6.22 bal4u
#include <stdio.h>
typedef long long ll;
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
ll in() { // 非負整数の入力
ll n = 0; int c = gc();
do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
return n;
}
void out(int n) { // 非負整数の表示(出力)
int i;
char b[20];
if (!n) pc('0');
else {
i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
while (i--) pc(b[i]);
}
pc('\n');
}
#define MOD 1000000009
#define LIM 90000
int dp[LIM+20];
int s[LIM+20];
int main()
{
int i, j, T, M;
for (i = 0; i <= LIM; i++) dp[i] = 1;
for (i = 2; i < 10; i++) {
for (j = 0; j <= LIM; j++) dp[j+i] = (dp[j+i] + dp[j]) % MOD;
}
for (i = 0; i <= LIM; i++) s[i+1] += (s[i] + dp[i]) % MOD;
T = (int)in();
while (T--) {
M = (int)(in() / 111111);
out(s[M+1]);
}
return 0;
}
bal4u