QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#501502 | #5158. Interview Question | Umok | WA | 0ms | 3836kb | C++20 | 1.5kb | 2024-08-02 19:40:27 | 2024-08-02 19:40:27 |
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 = 1000001;
if (d == 0)
d = 1000001;
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: 3464kb
input:
7 11 7 8 Fizz Buzz 11
output:
9 10
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
49999 50002 49999 FizzBuzz 50001 Fizz
output:
2 50000
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
8 11 Buzz Buzz FizzBuzz Buzz
output:
10 1
result:
ok
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3596kb
input:
10 15 10 11 12 13 14 15
output:
1000001 1000001
result:
wrong answer Integer parameter [name=a] equals to 1000001, violates the range [1, 1000000]