QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#226521 | #6226. 取石子 | NYCU_Yamada | 100 ✓ | 45ms | 3852kb | C++20 | 2.5kb | 2023-10-26 02:07:07 | 2023-10-26 02:07:07 |
Judging History
answer
#ifndef Yamada
#define Yamada
#include Yamada __FILE__ Yamada
const int maxf = 89;
int F[maxf];
vector dp(maxf + 1, vector<int>(maxf + 1, 0));
void init() {
F[0] = F[1] = 1;
for (int i = 2; i < maxf; ++i) F[i] = F[i-1] + F[i-2];
for (int i = 1; i < maxf; ++i) {
for (int j = 1; j < maxf; ++j) {
dp[i][j] = dp[i-1][j] + (i <= j);
if (i >= 2) dp[i][j] += dp[i-2][j];
// debug(i, j, dp[i][j]);
}
}
}
void solve() {
int K, N; cin >> K >> N;
int k = upper_bound(F, F + maxf, K) - F - 1;
// debug(k);
int ans = 0, pre = maxf + 1;
for (int i = maxf - 1; i >= 1; --i) {
if (N >= F[i]) {
N -= F[i];
ans += dp[i-1][k]; // len = i-1
if (pre <= k) ++ans;
pre = i;
}
}
cout << ans << '\n';
}
signed main() {
IOS();
init();
int t = 1; cin >> t;
for (int i=1;i<=t;++i) solve();
return 0;
}
#else
#ifdef local
#define _GLIBCXX_DEBUG 1
#endif
#pragma GCC optimize ("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define double __float80
using pii = pair<int, int>;
template <typename T> using MaxHeap = std::priority_queue<T>;
template <typename T> using MinHeap = std::priority_queue<T, vector<T>, greater<T>>;
#define SZ(a) ((int)(a).size())
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define ee emplace
#define eb emplace_back
#define ef emplace_front
#define pb pop_back
#define pf pop_front
// #define X first
// #define Y second
#ifdef local
#define IOS() void()
#define debug(...) \
fprintf(stderr, "\e[1;93m"), \
fprintf(stderr, "At [%s], line %d: (%s) = ", __FUNCTION__, __LINE__, #__VA_ARGS__), \
_do(__VA_ARGS__), \
fprintf(stderr, "\e[0m")
template <typename T> void _do(T &&_t) {cerr << _t << '\n';}
template <typename T, typename ...U> void _do(T &&_t, U &&..._u) {cerr << _t << ", ", _do(_u...);}
#define print(...) \
fprintf(stderr, "\e[1;96m"), \
_P(__VA_ARGS__), \
fprintf(stderr, "\e[0m")
#else
#define IOS() ios_base::sync_with_stdio(0); cin.tie(0)
#define debug(...) void()
#define print(...) _P(__VA_ARGS__)
#define endl '\n'
#endif
template <typename U, typename V> bool chmin(U &u, V v) {return u > v ? u = v, 1 : 0;}
template <typename U, typename V> bool chmax(U &u, V v) {return u < v ? u = v, 1 : 0;}
template <typename T> void _P(T &&_x) {cout << _x << '\n';}
template <typename T, typename ...S> void _P(T &&_x, S &&..._t) {cout << _x << " "; _P(_t...);}
#endif
詳細信息
Test #1:
score: 10
Accepted
time: 1ms
memory: 3620kb
input:
499 336 455 5 9 420 424 35 57 9 424 55 71 38 414 64 346 42 480 18 212 37 249 82 488 6 190 75 165 51 272 13 37 29 143 44 195 71 175 149 180 42 245 62 376 193 285 47 207 128 145 5 209 281 329 9 437 258 296 2 31 70 240 268 356 21 93 147 180 79 115 63 106 112 443 219 305 332 476 47 450 134 290 51 89 243...
output:
453 7 423 55 386 70 405 341 469 200 243 481 162 162 266 34 138 191 172 179 239 371 283 202 143 178 328 397 295 19 236 355 89 179 113 104 439 303 474 440 287 87 387 248 10 342 220 237 179 55 180 21 240 424 303 135 30 35 225 456 307 339 130 119 412 410 144 317 436 94 295 151 127 413 271 376 399 98 195...
result:
ok 499 lines
Test #2:
score: 10
Accepted
time: 12ms
memory: 3672kb
input:
49875 14399 29607 6224 29914 1106 26641 17 26569 6365 25718 27 4637 1618 2714 33573 40913 35563 36097 8973 28132 5673 25161 17636 34907 6000 10087 4467 7440 8334 49937 259 20572 6268 28505 6401 15802 12571 13234 23041 27538 2493 47406 5802 10423 11962 30757 3300 3837 8350 20422 225 16103 23645 34285...
output:
29604 29908 26621 25088 25713 4477 2712 40912 36096 28129 25156 34904 10085 7438 49931 20508 28500 15799 13233 27537 47384 10421 30754 3836 20419 16022 34283 14143 11943 3085 26304 4187 45877 6744 2564 6583 41136 24161 24495 3581 20250 1596 1768 42297 36849 39560 1567 19248 5957 29387 18796 41587 42...
result:
ok 49875 lines
Test #3:
score: 10
Accepted
time: 23ms
memory: 3608kb
input:
94256 53191 66970 85363 96281 23759 25693 28568 43227 27 31316 10224 32226 9111 25249 16987 19389 15006 30353 9523 59244 42546 55606 6039 6830 5609 54488 2509 12330 29480 70960 14785 65267 60831 91903 281 18175 31994 76610 3582 9689 7665 34764 12673 18964 16448 22115 5748 30321 33618 49834 18843 244...
output:
66969 96280 25692 43225 30237 32222 25246 19387 30350 59237 55604 6828 54478 12324 70958 65262 91901 18118 76607 9686 34760 18962 22113 30315 49832 24425 70059 40152 56259 57054 14261 45339 15707 14217 55632 98631 52711 24035 98749 39748 89561 80981 18906 48683 22461 41206 97044 74800 91011 49044 98...
result:
ok 94256 lines
Test #4:
score: 10
Accepted
time: 0ms
memory: 3820kb
input:
3 34279 810634 918771 1021048 25 42120
output:
810613 1021047 40669
result:
ok 3 lines
Test #5:
score: 10
Accepted
time: 0ms
memory: 3616kb
input:
3 690379 1982172 417599 1708659 1717080 2863950
output:
1982169 1708655 2863948
result:
ok 3 lines
Test #6:
score: 10
Accepted
time: 1ms
memory: 3688kb
input:
944 1 343954967570505156 1 84731075985818925 1 138311144113583007 1 104547054550584433 1 693241347397247084 1 472332079344024358 1 156793474620214247 1 850344749061699637 1 803512580085688163 1 310836022836048564 1 495053169351075063 1 82844446500137324 1 178945557527795821 1 216483389996708327 1 59...
output:
131379107012565125 32364391123232826 52830156028503762 39933421414633890 264794632298974933 180414800332505167 59889778090727832 324802791986569006 306914495204610982 118728795795532068 189093484453752948 31643762783880187 68351120839818397 82689296978943594 226609373538521525 31210098343021365 1747...
result:
ok 944 lines
Test #7:
score: 10
Accepted
time: 35ms
memory: 3688kb
input:
91665 1 367380666905152293 1 182005789689897190 1 623096247285159354 1 671594325644512277 1 742160204799780654 1 794275980040994924 1 74354650304567324 1 911166360819358930 1 764757676441890048 1 752269248988307295 1 955093740058796962 1 747803753737785010 1 404138290206507311 1 181396406609700806 1...
output:
140326927948164534 69520025512275542 238001588200421479 256526205744638559 283479973135933361 303386427928026962 28400949194731997 348034580427444623 292111439243407250 287341284422175938 364813346260203446 285635617013077651 154367090703617032 69287261887809626 23433513534972568 245586033973105615 ...
result:
ok 91665 lines
Test #8:
score: 10
Accepted
time: 0ms
memory: 3852kb
input:
911 78374152724567593 983112666946547816 753553157811176669 788891899819251115 33856693441045857 281513707367405940 458492126183900287 469318687938414816 20297113357777935 33378284552002778 10115955709864055 787679629225677540 17150232293760847 102828488233093971 112680441700253174 12938526751175947...
output:
983112666946547804 788891899819251114 281513707367405931 469318687938414815 33378284552002776 787679629225677476 102828488233093965 129385267511759476 393578058742371563 710310834833243826 96936676611661623 735136776039311809 198814605441753839 180714195277663471 595056197625354637 81570251109792082...
result:
ok 911 lines
Test #9:
score: 10
Accepted
time: 41ms
memory: 3680kb
input:
98295 873150664261731328 951581568702046682 56 727890463110977051 859978062141145093 947945138127019948 330253590080540990 768615565614466064 13256179404231692 95760438247048090 638707615934448347 792288571729874417 54711657924896980 847301161318887407 856185831773980409 893587664123567425 312798854...
output:
951581568702046681 718314614598993502 947945138127019947 768615565614466061 95760438247048082 792288571729874415 847301161318887390 893587664123567424 537497297873269823 9294212206362214 658682178594527622 905480424268227148 325786925372156416 562180168829403836 53899373768465925 713229827374765299 ...
result:
ok 98295 lines
Test #10:
score: 10
Accepted
time: 45ms
memory: 3664kb
input:
91640 405786310369032226 553800146036810186 84 288402474700211717 19845023439645913 392170479523345754 597697212044203925 702078911619194971 11204130783741609 13290697100124817 23 484543424049569697 559463321235963921 601484656718057819 227796568880241875 992739563025444500 156735875816653837 901104...
output:
553800146036810184 284608362058033389 392170479523345734 702078911619194969 13290697100124816 467854850303592542 601484656718057818 992739563025444495 901104214479350060 48697612993165859 734901520058359731 279043494845859133 114370108376756251 853502730432930234 262119937602158135 18879980688626615...
result:
ok 91640 lines