QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#417760 | #5158. Interview Question | yuyutw | WA | 1ms | 3736kb | C++14 | 1.4kb | 2024-05-22 21:46:23 | 2024-05-22 21:46:28 |
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(b.size()==1){
ans = gc/abs(gc-gb);
cout << ans << " " << abs(gc-gb) << endl;
}
else{
ans = gc/gb;
cout << ans << " " << gb << endl;
}
}
else if(ga!=0&&gb==0){
if(a.size()==1){
ans = gc/abs(gc-ga);
cout << abs(gc-ga) << " " << ans << endl;
}
else{
ans = gc/ga;
cout << ga << " " << ans << endl;
}
} else if(ga==0&&gb==0) {
cout << d+1 << " " << d+2 << endl;
} else {
cout << ga << " " << gb << endl;
}
}
int main() {
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3492kb
input:
7 11 7 8 Fizz Buzz 11
output:
9 10
result:
ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3468kb
input:
49999 50002 49999 FizzBuzz 50001 Fizz
output:
2 25000
result:
ok
Test #3:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
8 11 Buzz Buzz FizzBuzz Buzz
output:
10 1
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
10 15 10 11 12 13 14 15
output:
16 17
result:
ok
Test #5:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
17 17 17
output:
18 19
result:
ok
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3504kb
input:
13 13 Fizz
output:
13 0
result:
wrong answer Integer parameter [name=b] equals to 0, violates the range [1, 1000000]