結果
問題 | No.42 貯金箱の溜息 |
ユーザー | satanic |
提出日時 | 2020-08-26 20:15:37 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 13,297 bytes |
コンパイル時間 | 1,373 ms |
コンパイル使用メモリ | 122,416 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 13:35:05 |
合計ジャッジ時間 | 1,782 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
5,248 KB |
testcase_01 | AC | 5 ms
5,248 KB |
testcase_02 | AC | 6 ms
5,248 KB |
ソースコード
// // S i r o t a n w a t c h e s o v e r y o u . // // ...Jggg+J+JJJg@NQmgJa....., // ....gH@@@@HHB""""7"YYYYHMMMMMMM@@@@@@@Hma,. // ...JH@@MMHY"! ? __""YH@@@@N&... // ..JH@@HY"~ _TW@@@Mme. // .Jg@@#"= _TTM@@N.. // .Jg@@MY! ?T@@@h,. // .-@@@B! (TM@@@L // .(H@MY ?W@@@+ // .W@@@ .T@@@[ // .d@@M! .T@@N, // .d@M@' -W@@o. // (@@M\ ?M@N, // -d@M% .., .., j@@b // d@@M= TM9 ?MD W@@[ // .H@M: .W@H, // H@Ht ,@@# // (@@M~ .@@h. // .@@M% ..gmHHJ. .JdHga. .H@@e // j@@#_ .@@@@@@@b J@@@@@@@h. .H@@\ // d@@@ .4@@@@@@MF (@@@@@@@@ H@@b // d@@[ ?"BMY"= .d@@@@H, ?TWHHY"! d@@e // J@@b .JJJ-.., ,@@@@@@M% ......... -@@@M. // ?@@M\ ?YHHM@@@@b .. .W@@HP X@@HMWY"= d@@@# // ,@@@L. ?H@Ng&+gd@@#H@@NHaJ+gH@[ J@@@] // X@@@[ ...... ?"YYYYY"" ?"YHHHB"^ ..... (@@@# // WH@N+. .W@@@@MHB= .TWH@M@Hmc .H@@M~ // .H@@@@N, _!~ .d@@@N, // .J@@#T@@@N, .d@@@@@@@b. // (@@@@! .T@@@n, .(H@@@H>.W@@@x // (@@@F 4@@@@MaJ. .d@@@@Y77 4@@@r //.H@@P ?TM@@@@N... .-JH@HMY= d@@N, //(@@@F ?"WM@@@MQa-,. .(J(JN@@M#" Z@@@L // d@@H, (M@@@@@@@Ng&maJ.... .. ...J.J+W@@@@@@HY! .dH@b // ?M@@@N&. ..(JW@@@MM"?7""TYHMH@@HH@@@@@HHHgkHagHa(mggdmmagH@H@@Q@@HMMMHY"7!TMM@@@HaJ,. ..H@@@M^ // ?"W@@@@MN@@@@@H@@MMY" _???!"= ?WMMBYYTMH=7""Y@""?"~^ _"YM@@@@@@@@MH@@@@@#"^ // ?77WMMMYB""! _7"WWMMMY"7= // need #include <iostream> #include <algorithm> // data structure #include <bitset> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #include <complex> //#include <deque> #include <valarray> #include <unordered_map> #include <unordered_set> #include <array> // etc #include <cassert> #include <cmath> #include <functional> #include <iomanip> #include <chrono> #include <random> #include <numeric> #include <fstream> //std::ifstream ifs("b.in"); //auto& scan_in = ifs; auto& scan_in = std::cin; // input #define INIT std::ios::sync_with_stdio(false);std::cin.tie(0); #define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); template<typename T> void MACRO_VAR_Scan(T& t) { scan_in >> t; } template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest& ...rest) { scan_in >> first; MACRO_VAR_Scan(rest...); } #define VEC_ROW(type, n, ...)std::vector<type> __VA_ARGS__;MACRO_VEC_ROW_Init(n, __VA_ARGS__); for(int w_=0; w_<n; ++w_){MACRO_VEC_ROW_Scan(w_, __VA_ARGS__);} template<typename T> void MACRO_VEC_ROW_Init(int n, T& t) { t.resize(n); } template<typename First, typename...Rest>void MACRO_VEC_ROW_Init(int n, First& first, Rest& ...rest) { first.resize(n); MACRO_VEC_ROW_Init(n, rest...); } template<typename T> void MACRO_VEC_ROW_Scan(int p, T& t) { scan_in >> t[p]; } template<typename First, typename...Rest>void MACRO_VEC_ROW_Scan(int p, First& first, Rest& ...rest) { scan_in >> first[p]; MACRO_VEC_ROW_Scan(p, rest...); } #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)scan_in>>i; #define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& R:c)for(auto& w:R)scan_in>>w; // output template<typename T>void MACRO_OUT(const T t) { std::cout << t; } template<typename First, typename...Rest>void MACRO_OUT(const First first, const Rest...rest) { std::cout << first << " "; MACRO_OUT(rest...); } #define OUT(...) MACRO_OUT(__VA_ARGS__); #define FOUT(n, dist) std::cout<<std::fixed<<std::setprecision(n)<<(dist); #define SOUT(n, c, dist) std::cout<<std::setw(n)<<std::setfill(c)<<(dist); #define VOUT(v) for(size_t i = 0; i < v.size(); ++i) {OUT(v[i]);if(i+1<v.size()){SP}} #define EOUT(...) do{ OUT(__VA_ARGS__)BR; exit(0); }while(0); #define SP std::cout<<" "; #define TAB std::cout<<"\t"; #define BR std::cout<<"\n"; #define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' '); #define ENDL std::cout<<std::endl; #define FLUSH std::cout<<std::flush; #define SHOW(dist) {std::cerr << #dist << "\t: " << (dist) << "\n";} // utility #define ALL(a) (a).begin(),(a).end() #define FOR(w, a, n) for(int w=(a);w<(n);++w) #define REP(w, n) FOR(w, 0, n) #define RFOR(w, a, n) for(int w=(n)-1;w>=(a);--w) #define RREP(w, n) RFOR(w, 0, n) template<class S, class T, class U> bool IN(S a, T x, U b) { return a <= x && x < b; } template<class T> inline T CHMAX(T& a, const T b) { return a = (a < b) ? b : a; } template<class T> inline T CHMIN(T& a, const T b) { return a = (a > b) ? b : a; } // test template<class T> using V = std::vector<T>; template<class T> using VV = V<V<T>>; template<typename S, typename T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; } template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) { os << "{"; for (size_t i = 0; i < v.size(); ++i) os << v[i] << ((i + 1 < v.size()) ? ", " : ""); os << "}"; return os; } template<typename T> std::ostream & operator<<(std::ostream & os, const std::set<T> & v) { os << "{"; for (auto it = v.cbegin();;) { os << *it; ++it; if (it == v.cend()) { os << "}"; break; } else { os << ", "; } } return os; } template<typename S, typename T> std::ostream& operator<<(std::ostream & os, const std::map<S, T> & m) { os << "{"; for (auto it = m.cbegin(); it != m.cend();) { os << it->first << ":" << it->second; ++it; os << (it == m.cend() ? "" : ", "); } os << "}"; return os; } template<typename T> std::ostream& operator<<(std::ostream & os, std::queue<T> q) { os << "<"; while (!q.empty()) { os << q.front(); q.pop(); os << (q.empty() ? "<" : ", "); } return os; } template<typename T> std::ostream& operator<<(std::ostream & os, std::stack<T> q) { os << ">"; while (!q.empty()) { os << q.top(); q.pop(); os << (q.empty() ? "]" : ", "); } return os; } namespace std { template<typename S, typename T> class numeric_limits<pair<S, T>> { public: static constexpr pair<S, T> max() noexcept { return { numeric_limits<S>::max(), numeric_limits<T>::max() }; } static constexpr pair<S, T> lowest() noexcept { return { numeric_limits<S>::lowest(), numeric_limits<T>::lowest() }; } }; } // type/const using i64 = std::int_fast64_t; using u64 = std::uint_fast64_t; using ll = long long; using ull = unsigned long long; using ld = long double; using PAIR = std::pair<int, int>; using PAIRLL = std::pair<ll, ll>; constexpr int INFINT = (1 << 30) - 1; // 1.07x10^ 9 constexpr int INFINT_LIM = (1LL << 31) - 1; // 2.15x10^ 9 constexpr ll INFLL = 1LL << 60; // 1.15x10^18 constexpr ll INFLL_LIM = (1LL << 62) - 1 + (1LL << 62); // 9.22x10^18 constexpr double EPS = 1e-6; constexpr i64 MOD = 1000000009; constexpr double PI = 3.141592653589793238462643383279; template<class T, size_t N> void FILL(T(&a)[N], const T & val) { for (auto& x : a) x = val; } template<class ARY, size_t N, size_t M, class T> void FILL(ARY(&a)[N][M], const T & val) { for (auto& b : a) FILL(b, val); } template<class T> void FILL(std::vector<T> & a, const T & val) { for (auto& x : a) x = val; } template<class ARY, class T> void FILL(std::vector<std::vector<ARY>> & a, const T & val) { for (auto& b : a) FILL(b, val); } // ------------>8--------- i64 C(i64 n) { ll ans = 591666672; n %= MOD; for (int i = 0; i < 5; ++i) (ans *= n - i) %= MOD; if (ans < 0) ans += MOD; return ans; } int P[] = { 1, 2, 4, 6, 9, 12, 16, 20, 25, 30, 37, 44, 53, 62, 73, 84, 97, 110, 125, 140, 159, 178, 201, 224, 251, 278, 309, 340, 375, 410, 451, 492, 539, 586, 639, 692, 751, 810, 875, 940, 1014, 1088, 1171, 1254, 1346, 1438, 1539, 1640, 1750, 1860, 1982, 2104, 2238, 2372, 2518, 2664, 2822, 2980, 3150, 3320, 3506, 3692, 3894, 4096, 4314, 4532, 4766, 5000, 5250, 5500, 5770, 6040, 6330, 6620, 6930, 7240, 7570, 7900, 8250, 8600, 8975, 9350, 9750, 10150, 10575, 11000, 11450, 11900, 12375, 12850, 13355, 13860, 14395, 14930, 15495, 16060, 16655, 17250, 17875, 18500, 19156, 19812, 20499, 21186, 21904, 22622, 23371, 24120, 24900, 25680, 26492, 27304, 28148, 28992, 29868, 30744, 31652, 32560, 33500, 34440, 35409, 36378, 37376, 38374, 39401, 40428, 41484, 42540, 43625, 44710, 45821, 46932, 48069, 49206, 50369, 51532, 52721, 53910, 55125, 56340, 57574, 58808, 60061, 61314, 62586, 63858, 65149, 66440, 67750, 69060, 70382, 71704, 73038, 74372, 75718, 77064, 78422, 79780, 81150, 82520, 83891, 85262, 86634, 88006, 89379, 90752, 92126, 93500, 94875, 96250, 97615, 98980, 100335, 101690, 103035, 104380, 105715, 107050, 108375, 109700, 111000, 112300, 113575, 114850, 116100, 117350, 118575, 119800, 121000, 122200, 123360, 124520, 125640, 126760, 127840, 128920, 129960, 131000, 132000, 133000, 133951, 134902, 135804, 136706, 137559, 138412, 139216, 140020, 140775, 141530, 142227, 142924, 143563, 144202, 144783, 145364, 145887, 146410, 146875, 147340, 147744, 148148, 148491, 148834, 149116, 149398, 149619, 149840, 150000, 150160, 150256, 150352, 150384, 150416, 150384, 150352, 150256, 150160, 150000, 149840, 149619, 149398, 149116, 148834, 148491, 148148, 147744, 147340, 146875, 146410, 145887, 145364, 144783, 144202, 143563, 142924, 142227, 141530, 140775, 140020, 139216, 138412, 137559, 136706, 135804, 134902, 133951, 133000, 132000, 131000, 129960, 128920, 127840, 126760, 125640, 124520, 123360, 122200, 121000, 119800, 118575, 117350, 116100, 114850, 113575, 112300, 111000, 109700, 108375, 107050, 105715, 104380, 103035, 101690, 100335, 98980, 97615, 96250, 94875, 93500, 92126, 90752, 89379, 88006, 86634, 85262, 83891, 82520, 81150, 79780, 78422, 77064, 75718, 74372, 73038, 71704, 70382, 69060, 67750, 66440, 65149, 63858, 62586, 61314, 60061, 58808, 57574, 56340, 55125, 53910, 52721, 51532, 50369, 49206, 48069, 46932, 45821, 44710, 43625, 42540, 41484, 40428, 39401, 38374, 37376, 36378, 35409, 34440, 33500, 32560, 31652, 30744, 29868, 28992, 28148, 27304, 26492, 25680, 24900, 24120, 23371, 22622, 21904, 21186, 20499, 19812, 19156, 18500, 17875, 17250, 16655, 16060, 15495, 14930, 14395, 13860, 13355, 12850, 12375, 11900, 11450, 11000, 10575, 10150, 9750, 9350, 8975, 8600, 8250, 7900, 7570, 7240, 6930, 6620, 6330, 6040, 5770, 5500, 5250, 5000, 4766, 4532, 4314, 4096, 3894, 3692, 3506, 3320, 3150, 2980, 2822, 2664, 2518, 2372, 2238, 2104, 1982, 1860, 1750, 1640, 1539, 1438, 1346, 1254, 1171, 1088, 1014, 940, 875, 810, 751, 692, 639, 586, 539, 492, 451, 410, 375, 340, 309, 278, 251, 224, 201, 178, 159, 140, 125, 110, 97, 84, 73, 62, 53, 44, 37, 30, 25, 20, 16, 12, 9, 6, 4, 2, 1 }; signed main() { INIT; auto Q = [&](i64 m) { return C(m / 100 + 5); }; VAR(int, T); REP(_, T) { VAR(i64, m); m /= 5; i64 ans = 0; i64 lim = std::max((i64)0, m - 466); for (i64 k = m / 100 * 100; k >= lim; k -= 100) (ans += P[m - k] * Q(k)) %= MOD; OUT(ans)BR; } return 0; }