QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#142316 | #5158. Interview Question | Khaled_Ramadan# | WA | 1ms | 3464kb | C++20 | 1.4kb | 2023-08-18 22:45:43 | 2023-08-18 22:45:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
typedef long long ll;
const long long N = 3e5 + 7, Mod = 1e9 + 7, INF = 2e18;
ll inv(ll a, ll b = Mod) { return 1 < a ? b - inv(b % a, a) * b / a : 1; }
const int dx[9] = {0, 0, 1, -1, 1, 1, -1, -1, 0};
const int dy[9] = {1, -1, 0, 0, -1, 1, 1, -1, 0};
void solve()
{
ll c, d;
cin >> c >> d;
ll gcF = 0, gcB = 0, lcFB = 1;
for (int i = c; i <= d; i++)
{
string s;
cin >> s;
if (s == "Fizz")
{
gcF = gcd(gcF, i);
}
if (s == "Buzz")
{
gcB = gcd(gcB, i);
}
if (s == "FizzBuzz")
{
lcFB = lcm(lcFB, i);
}
}
ll x = gcd(lcFB, gcF);
ll y = gcd(lcFB, gcB);
if (gcB == 0 and gcB == 0)
{
cout << d + 1 << " " << d + 1 << endl;
return;
}
if (lcFB == 1)
{
cout << gcF << " " << gcB << endl;
return;
}
if (gcF == 0 or gcB == 0)
{
ll ans = gcd(lcFB, gcd(gcF, gcB));
cout << ans << " " << ans << endl;
return;
}
// cout << gcF << " " << gcB << " " << lcFB << endl;
cout << x << " " << y << endl;
// ll a = gcF / x, b = gcB / y;
// cout << a << " " << b << endl;
}
int main()
{
IO;
int TC = 1;
// cin >> TC;
while (TC--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3464kb
input:
7 11 7 8 Fizz Buzz 11
output:
9 10
result:
ok
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3460kb
input:
49999 50002 49999 FizzBuzz 50001 Fizz
output:
50003 50003
result:
FAIL Mismatch at position 50000: expected FizzBuzz, got 50000