QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#501499#5158. Interview QuestionUmokWA 0ms5656kbC++201.3kb2024-08-02 19:34:142024-08-02 19:34:15

Judging History

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

  • [2024-08-02 19:34:15]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:5656kb
  • [2024-08-02 19:34:14]
  • 提交

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(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: 3616kb

input:

7 11
7 8 Fizz Buzz 11

output:

9 10

result:

ok 

Test #2:

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

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: 0
Accepted
time: 0ms
memory: 3532kb

input:

10 15
10 11 12 13 14 15

output:

100000 100000

result:

ok 

Test #5:

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

input:

17 17
17

output:

100000 100000

result:

ok 

Test #6:

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

input:

13 13
Fizz

output:

13 100000

result:

ok 

Test #7:

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

input:

20 20
Buzz

output:

100000 20

result:

ok 

Test #8:

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

input:

30 30
FizzBuzz

output:

30 30

result:

ok 

Test #9:

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

input:

9 10
Buzz FizzBuzz

output:

10 1

result:

ok 

Test #10:

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

input:

2 6
2 3 4 5 FizzBuzz

output:

6 6

result:

ok 

Test #11:

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

input:

6 7
Fizz 7

output:

6 100000

result:

ok 

Test #12:

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

input:

7 8
Buzz Buzz

output:

100000 1

result:

ok 

Test #13:

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

input:

4 8
4 5 Buzz 7 8

output:

100000 6

result:

ok 

Test #14:

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

input:

33 50
Buzz 34 35 FizzBuzz 37 38 Buzz 40 41 FizzBuzz 43 44 Buzz 46 47 FizzBuzz 49 50

output:

3 3

result:

FAIL Mismatch at position 33: expected Buzz, got FizzBuzz