QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#501501 | #5158. Interview Question | Umok | WA | 3ms | 5784kb | C++20 | 1.5kb | 2024-08-02 19:39:38 | 2024-08-02 19:39:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N = 1e6 + 5;
#define int long long
typedef pair<int, int> PII;
#define MAX LONG_LONG_MAX
int ar[N];
int gcd(int a, int b)
{
return b ? gcd(b, a % b) : a;
}
void solve()
{
int a, b;
cin >> a >> b;
int c = 0, d = 0;
for (int i = a; i <= b; i++)
{
string s;
cin >> s;
if (s == "Fizz")
{
if (c == 0)
c = i;
else
c = gcd(c, i);
}
else if (s == "Buzz")
{
if (d == 0)
d = i;
else
d = gcd(d, i);
}
else if (s == "FizzBuzz")
{
if (d == 0 || c == 0)
{
if (c == 0 && d == 0)
{
c = d = i;
}
else if (d == 0)
{
d = i;
c = gcd(c, i);
}
else
{
c = i, d = gcd(d, i);
}
}
else
{
d = gcd(d, i);
c = gcd(c, i);
}
}
else
ar[i] = i;
}
if (c == 0)
c = 100000;
if (d == 0)
d = 100000;
cout << c << " " << d << endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3768kb
input:
7 11 7 8 Fizz Buzz 11
output:
9 10
result:
ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 5664kb
input:
49999 50002 49999 FizzBuzz 50001 Fizz
output:
2 50000
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
8 11 Buzz Buzz FizzBuzz Buzz
output:
10 1
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
10 15 10 11 12 13 14 15
output:
100000 100000
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
17 17 17
output:
100000 100000
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
13 13 Fizz
output:
13 100000
result:
ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
20 20 Buzz
output:
100000 20
result:
ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
30 30 FizzBuzz
output:
30 30
result:
ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
9 10 Buzz FizzBuzz
output:
10 1
result:
ok
Test #10:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
2 6 2 3 4 5 FizzBuzz
output:
6 6
result:
ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
6 7 Fizz 7
output:
6 100000
result:
ok
Test #12:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
7 8 Buzz Buzz
output:
100000 1
result:
ok
Test #13:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
4 8 4 5 Buzz 7 8
output:
100000 6
result:
ok
Test #14:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
33 50 Buzz 34 35 FizzBuzz 37 38 Buzz 40 41 FizzBuzz 43 44 Buzz 46 47 FizzBuzz 49 50
output:
6 3
result:
ok
Test #15:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
32 47 32 33 34 35 FizzBuzz 37 38 39 40 41 FizzBuzz 43 44 45 46 47
output:
6 6
result:
ok
Test #16:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
9 72 9 FizzBuzz 11 12 13 14 15 16 17 18 19 FizzBuzz 21 22 23 24 25 26 27 28 29 FizzBuzz 31 32 33 34 35 36 37 38 39 FizzBuzz 41 42 43 44 45 46 47 48 49 FizzBuzz 51 52 53 54 55 56 57 58 59 FizzBuzz 61 62 63 64 65 66 67 68 69 FizzBuzz 71 72
output:
10 10
result:
ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
55 59 55 Fizz 57 Fizz 59
output:
2 100000
result:
ok
Test #18:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
35 65 Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz
output:
1 2
result:
ok
Test #19:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
3 6 3 4 5 6
output:
100000 100000
result:
ok
Test #20:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
4 5 4 5
output:
100000 100000
result:
ok
Test #21:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
3 10 3 4 5 6 7 8 9 10
output:
100000 100000
result:
ok
Test #22:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
2 4 2 3 4
output:
100000 100000
result:
ok
Test #23:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
3 4 3 4
output:
100000 100000
result:
ok
Test #24:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
1 67 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
output:
100000 100000
result:
ok
Test #25:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
45 73 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 Fizz 61 62 63 64 65 66 67 68 69 70 71 Buzz 73
output:
60 72
result:
ok
Test #26:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
23 85 23 Fizz 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 Fizz 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 Fizz 73 74 75 76 77 78 79 80 81 82 83 84 85
output:
24 100000
result:
ok
Test #27:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
2 3 2 3
output:
100000 100000
result:
ok
Test #28:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
8 64 8 9 10 Buzz 12 13 14 15 16 17 18 19 20 21 Buzz 23 24 25 26 27 28 29 30 31 32 Buzz 34 35 36 37 38 39 40 41 42 43 Buzz 45 46 47 48 49 Fizz 51 52 53 54 Buzz 56 57 58 59 60 61 62 63 64
output:
50 11
result:
ok
Test #29:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
5 8 Fizz 6 7 8
output:
5 100000
result:
ok
Test #30:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
1 7 1 2 3 Fizz 5 6 7
output:
4 100000
result:
ok
Test #31:
score: 0
Accepted
time: 3ms
memory: 4572kb
input:
1 100000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
40998 1272
result:
ok
Test #32:
score: 0
Accepted
time: 3ms
memory: 4572kb
input:
1 100000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
91361 68433
result:
ok
Test #33:
score: 0
Accepted
time: 3ms
memory: 4364kb
input:
1 100000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
21325 59645
result:
ok
Test #34:
score: 0
Accepted
time: 3ms
memory: 4568kb
input:
1 100000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
34583 27663
result:
ok
Test #35:
score: 0
Accepted
time: 3ms
memory: 4328kb
input:
1 100000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
86161 37409
result:
ok
Test #36:
score: 0
Accepted
time: 3ms
memory: 4124kb
input:
24456 98977 24456 24457 24458 24459 24460 24461 24462 24463 24464 24465 24466 24467 24468 24469 24470 24471 24472 24473 24474 24475 24476 24477 24478 24479 24480 24481 24482 24483 24484 24485 24486 24487 24488 24489 24490 24491 24492 24493 24494 24495 24496 24497 24498 24499 24500 24501 24502 24503 ...
output:
609 447
result:
ok
Test #37:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
54773 62280 54773 54774 54775 54776 54777 54778 54779 54780 54781 54782 54783 54784 54785 54786 54787 54788 54789 54790 54791 54792 54793 54794 54795 54796 54797 54798 54799 54800 54801 54802 54803 54804 54805 54806 54807 54808 54809 54810 54811 54812 54813 54814 54815 54816 54817 54818 54819 54820 ...
output:
496 547
result:
ok
Test #38:
score: 0
Accepted
time: 2ms
memory: 3940kb
input:
433 52306 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 50...
output:
822 207
result:
ok
Test #39:
score: 0
Accepted
time: 1ms
memory: 4080kb
input:
43481 80833 43481 43482 43483 43484 43485 43486 43487 43488 43489 43490 43491 43492 43493 43494 43495 43496 43497 43498 43499 43500 43501 43502 43503 43504 43505 43506 43507 43508 43509 43510 43511 43512 43513 43514 43515 43516 43517 43518 43519 43520 43521 43522 43523 43524 43525 43526 43527 43528 ...
output:
437 953
result:
ok
Test #40:
score: 0
Accepted
time: 2ms
memory: 5608kb
input:
22810 80643 22810 22811 22812 22813 22814 22815 22816 22817 22818 22819 22820 22821 22822 22823 22824 22825 22826 22827 22828 22829 22830 22831 22832 22833 22834 22835 22836 22837 22838 22839 22840 22841 22842 22843 22844 22845 22846 22847 22848 22849 22850 22851 22852 22853 22854 22855 22856 22857 ...
output:
768 88
result:
ok
Test #41:
score: 0
Accepted
time: 2ms
memory: 5784kb
input:
10950 48700 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 Buzz 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 1...
output:
559 90
result:
ok
Test #42:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
15394 53787 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 15441 ...
output:
854 458
result:
ok
Test #43:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
39911 75660 39911 39912 39913 39914 39915 39916 39917 39918 39919 39920 39921 39922 39923 39924 39925 39926 39927 39928 39929 39930 39931 39932 39933 39934 39935 39936 39937 39938 39939 39940 39941 39942 39943 39944 39945 39946 39947 39948 39949 39950 39951 39952 39953 39954 39955 39956 39957 39958 ...
output:
591 98
result:
ok
Test #44:
score: 0
Accepted
time: 2ms
memory: 4260kb
input:
11093 93594 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 Buzz 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 1...
output:
534 117
result:
ok
Test #45:
score: 0
Accepted
time: 1ms
memory: 3548kb
input:
24531 31696 24531 24532 24533 24534 24535 24536 24537 24538 24539 24540 24541 24542 24543 24544 24545 24546 24547 24548 24549 24550 24551 24552 24553 24554 24555 24556 24557 24558 24559 24560 24561 24562 24563 24564 24565 24566 24567 24568 24569 24570 24571 24572 24573 24574 24575 24576 24577 24578 ...
output:
995 389
result:
ok
Test #46:
score: -100
Wrong Answer
time: 0ms
memory: 3492kb
input:
100000 100000 100000
output:
100000 100000
result:
FAIL Mismatch at position 100000: expected 100000, got FizzBuzz