QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#501502#5158. Interview QuestionUmokWA 0ms3836kbC++201.5kb2024-08-02 19:40:272024-08-02 19:40:27

Judging History

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

  • [2024-08-02 19:40:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3836kb
  • [2024-08-02 19:40:27]
  • 提交

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;
}

詳細信息

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]