結果
問題 | No.42 貯金箱の溜息 |
ユーザー | 👑 hos.lyric |
提出日時 | 2014-12-13 12:49:46 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 2,289 ms / 5,000 ms |
コード長 | 1,631 bytes |
コンパイル時間 | 696 ms |
コンパイル使用メモリ | 86,064 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-02 14:26:14 |
合計ジャッジ時間 | 6,795 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 470 ms
4,380 KB |
testcase_01 | AC | 2,289 ms
4,380 KB |
testcase_02 | AC | 2,230 ms
4,380 KB |
ソースコード
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <cassert> #include <iostream> #include <sstream> #include <string> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <utility> #include <numeric> #include <algorithm> #include <bitset> #include <complex> #include <unordered_set> #include <unordered_map> using namespace std; typedef unsigned uint; typedef long long Int; typedef vector<int> vint; typedef pair<int,int> pint; #define mp make_pair template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; } template<typename T> void chmin(T &t, const T &f) { if (t > f) t = f; } template<typename T> void chmax(T &t, const T &f) { if (t < f) t = f; } int in() { int x; scanf("%d", &x); return x; } const Int MO = 1000000009; Int M; Int dp[2048]; int main() { for (int TC = in(); TC--; ) { scanf("%lld", &M); memset(dp, 0, 667 << 3); dp[0] = 1; for (int l = 0; 1LL << l <= M; ++l) { memset(dp + 667, 0, 667 << 3); for (int x = 666 + 1; x >= 1; --x) dp[x] += dp[x - 1]; for (int x = 666 + 6; x >= 5; --x) dp[x] += dp[x - 5]; for (int x = 666 + 16; x >= 10; --x) dp[x] += dp[x - 10]; for (int x = 666 + 66; x >= 50; --x) dp[x] += dp[x - 50]; for (int x = 666 + 166; x >= 100; --x) dp[x] += dp[x - 100]; for (int x = 666 + 666; x >= 500; --x) dp[x] += dp[x - 500]; for (int x = 0; x <= 666; ++x) { dp[x] = dp[x << 1 | (M >> l & 1)] % MO; } } printf("%lld\n", dp[0]); } return 0; }