QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#417783 | #5158. Interview Question | yuyutw | WA | 1ms | 3736kb | C++14 | 2.0kb | 2024-05-22 22:07:38 | 2024-05-22 22:07:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void solve() {
int c, d;
cin >> c >> d;
vector<int> a, b, cc;
int ga = 0, gb = 0, gc = 0;
for(int i=0;i<d-c+1;i++) {
string tmp;
cin >> tmp;
if(tmp == "Fizz") {
a.push_back(c+i);
if(ga == 0)
ga = c+i;
else
ga = __gcd(c+i, ga);
} else if(tmp == "Buzz") {
b.push_back(c+i);
if(gb == 0)
gb = c+i;
else
gb = __gcd(c+i, gb);
} else if(tmp == "FizzBuzz") {
cc.push_back(c+i);
if(gc == 0)
gc = c+i;
else
gc = __gcd(c+i, gc);
}
}
int ans = 0;
if(ga==0&&gb!=0){
if(cc.size()==0){
cout << d+1 << " " << gb << endl;
} else if(b.size()==1){
ans = gc/abs(gc-gb);
cout << ans << " " << abs(gc-gb) << endl;
}
else{
ans = __gcd(gc,gb);
if(gb==1)
ans = gc;
cout << ans << " " << gb << endl;
}
}
else if(ga!=0&&gb==0){
if(cc.size()==0){
cout << ga << " " << d+1 << endl;
} else if(a.size()==1){
ans = gc/abs(gc-ga);
cout << abs(gc-ga) << " " << ans << endl;
}
else{
ans = __gcd(gc,ga);
if(ga==1)
ans = gc;
cout << ga << " " << ans << endl;
}
} else if(ga==0&&gb==0) {
if(cc.size()>=1){
int a1=0, b2=0;
for(int i=1;i<=gc;i++) {
if(gc%i==0) {
a1 = b2 = i;
}
}
cout << a1 << " " << b2 << endl;
} else{
cout << d+1 << " " << d+2 << endl;
}
} else {
cout << ga << " " << gb << endl;
}
}
int main() {
solve();
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3696kb
input:
7 11 7 8 Fizz Buzz 11
output:
9 10
result:
ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3492kb
input:
49999 50002 49999 FizzBuzz 50001 Fizz
output:
2 25000
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3508kb
input:
8 11 Buzz Buzz FizzBuzz Buzz
output:
10 1
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3456kb
input:
10 15 10 11 12 13 14 15
output:
16 17
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
17 17 17
output:
18 19
result:
ok
Test #6:
score: 0
Accepted
time: 1ms
memory: 3480kb
input:
13 13 Fizz
output:
13 14
result:
ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
20 20 Buzz
output:
21 20
result:
ok
Test #8:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
30 30 FizzBuzz
output:
30 30
result:
ok
Test #9:
score: 0
Accepted
time: 1ms
memory: 3540kb
input:
9 10 Buzz FizzBuzz
output:
10 1
result:
ok
Test #10:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
2 6 2 3 4 5 FizzBuzz
output:
6 6
result:
ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
6 7 Fizz 7
output:
6 8
result:
ok
Test #12:
score: 0
Accepted
time: 1ms
memory: 3696kb
input:
7 8 Buzz Buzz
output:
9 1
result:
ok
Test #13:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
4 8 4 5 Buzz 7 8
output:
9 6
result:
ok
Test #14:
score: -100
Wrong Answer
time: 0ms
memory: 3484kb
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