QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#501088 | #5158. Interview Question | Dreamy_Blaze | WA | 1ms | 3740kb | C++14 | 1.2kb | 2024-08-02 14:01:02 | 2024-08-02 14:01:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
map<string, int>m;
int a, b;
cin >> a >> b;
string s;
for (int i = a; i <= b; i++) {
cin >> s;
if (s == "Fizz") {
if (m[s]) {
m[s] = __gcd(m[s], i);
} else {
m[s] = i;
}
} else if (s == "Buzz") {
if (m[s]) {
m[s] = __gcd(m[s], i);
} else
m[s] = i;
} else if (s == "FizzBuzz") {
m[s] = i;
} else
m.insert(pair<string, int>(s, i));
}
if (m["FizzBuzz"]) {
if (!m["Buzz"]) {
m["Buzz"] = m["FizzBuzz"] / __gcd(m["FizzBuzz"], m["Fizz"]);
m["Fizz"] = __gcd(m["FizzBuzz"], m["Fizz"]);
}
if (!m["Fizz"]) {
m["Fizz"] = m["FizzBuzz"] / __gcd(m["FizzBuzz"], m["Buzz"]);
m["Buzz"] = __gcd(m["FizzBuzz"], m["Buzz"]);
}
}
if (m["Fizz"] == 0 || m["Buzz"] == 0) {
if (!m["Fizz"]) {
m["Fizz"] = b + 1;
}
if (!m["Buzz"]) {
m["Buzz"] = b + 2;
}
}
cout << m["Fizz"] << " " << m["Buzz"];
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3604kb
input:
7 11 7 8 Fizz Buzz 11
output:
9 10
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
49999 50002 49999 FizzBuzz 50001 Fizz
output:
2 25000
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
8 11 Buzz Buzz FizzBuzz Buzz
output:
10 1
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
10 15 10 11 12 13 14 15
output:
16 17
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
17 17 17
output:
18 19
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
13 13 Fizz
output:
13 15
result:
ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
20 20 Buzz
output:
21 20
result:
ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
30 30 FizzBuzz
output:
30 1
result:
ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
9 10 Buzz FizzBuzz
output:
10 1
result:
ok
Test #10:
score: -100
Wrong Answer
time: 0ms
memory: 3588kb
input:
2 6 2 3 4 5 FizzBuzz
output:
6 1
result:
FAIL Mismatch at position 2: expected 2, got Buzz