QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#501498#5158. Interview QuestionUmokWA 0ms3784kbC++201.5kb2024-08-02 19:33:082024-08-02 19:33:09

Judging History

你现在查看的是最新测评结果

  • [2024-08-02 19:33:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3784kb
  • [2024-08-02 19:33:08]
  • 提交

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 (d == 0)
                {
                    d = i;
                    c = gcd(c, i);
                }
                if (c == 0)
                    c = i, d = gcd(d, i);
            }
            else
            {
                d = c = gcd(d, c);
            }
        }
        else
            ar[i] = i;
    }
    if (a - 1 != 0)
    {
        if (c == 0)
            c = a - 1;
        if (d == 0)
            d = a - 1;
    }
    else
    {
        if (c == 0)
            c = b + 1;
        if (d == 0)
            d = b + 1;
    }

    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: 3548kb

input:

7 11
7 8 Fizz Buzz 11

output:

9 10

result:

ok 

Test #2:

score: 0
Accepted
time: 0ms
memory: 3468kb

input:

49999 50002
49999 FizzBuzz 50001 Fizz

output:

2 50000

result:

ok 

Test #3:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

8 11
Buzz Buzz FizzBuzz Buzz

output:

10 1

result:

ok 

Test #4:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

10 15
10 11 12 13 14 15

output:

9 9

result:

ok 

Test #5:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

17 17
17

output:

16 16

result:

ok 

Test #6:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

13 13
Fizz

output:

13 12

result:

ok 

Test #7:

score: 0
Accepted
time: 0ms
memory: 3784kb

input:

20 20
Buzz

output:

19 20

result:

ok 

Test #8:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

30 30
FizzBuzz

output:

30 30

result:

ok 

Test #9:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

9 10
Buzz FizzBuzz

output:

10 1

result:

ok 

Test #10:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

2 6
2 3 4 5 FizzBuzz

output:

6 6

result:

ok 

Test #11:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

6 7
Fizz 7

output:

6 5

result:

ok 

Test #12:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

7 8
Buzz Buzz

output:

6 1

result:

ok 

Test #13:

score: -100
Wrong Answer
time: 0ms
memory: 3608kb

input:

4 8
4 5 Buzz 7 8

output:

3 6

result:

FAIL Mismatch at position 6: expected Buzz, got FizzBuzz