QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#501504 | #5158. Interview Question | Umok | WA | 0ms | 3832kb | C++20 | 1.8kb | 2024-08-02 19:43:48 | 2024-08-02 19:43:49 |
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 || d == 0)
{
if (c == 0 && d == 0)
{
c = d = b + 1;
if (c > 10000)
{
c = d = a - 1;
}
}else
{
if(c == 0)
c == 10000;
if(d == 0)
d == 10000;
}
}
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: 3816kb
input:
7 11 7 8 Fizz Buzz 11
output:
9 10
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
49999 50002 49999 FizzBuzz 50001 Fizz
output:
2 50000
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
8 11 Buzz Buzz FizzBuzz Buzz
output:
10 1
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
10 15 10 11 12 13 14 15
output:
16 16
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
17 17 17
output:
18 18
result:
ok
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3488kb
input:
13 13 Fizz
output:
13 0
result:
wrong answer Integer parameter [name=b] equals to 0, violates the range [1, 1000000]