QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#417782 | #5151. Bottle Flip | yuyutw | WA | 1ms | 3504kb | C++14 | 2.0kb | 2024-05-22 22:07:14 | 2024-05-22 22:07:14 |
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();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3504kb
input:
22 4 1 4
output:
5 6
result:
wrong answer 1st numbers differ - expected: '7.3333333', found: '5.0000000', error = '0.3181818'