QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#201297 | #5158. Interview Question | PhantomThreshold# | WA | 7ms | 27240kb | C++20 | 1.7kb | 2023-10-05 13:34:55 | 2023-10-05 13:34:55 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
int gcd(int a,int b){ return !a?b:gcd(b%a,a); }
const int maxn = 1010000;
int L,R;
int a[maxn],b[maxn],ab[maxn];
int oka[maxn],okb[maxn],okab[maxn];
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>L>>R;
int lasa=-1,lasb=-1,lasab=-1;
int A=0,B=0,AB=0;
for(int i=L;i<=R;i++)
{
string str; cin>>str;
if(str[0]=='F')
{
a[i]=1;
if(str.size()>4) ab[i]=1,b[i]=1;
}
if(str[0]=='B')
{
b[i]=1;
}
if(a[i])
{
if(lasa!=-1) A=i-lasa;
lasa=i;
}
if(b[i])
{
if(lasb!=-1) B=i-lasb;
lasb=i;
}
if(ab[i])
{
if(lasab!=-1) AB=i-lasab;
lasab=i;
}
}
if(A==0)
{
if(lasa==-1)
{
for(int i=1;i<L;i++) oka[i]=1;
for(int i=R+1;i<maxn;i++) oka[i]=1;
}
else
{
for(int i=1;i<maxn;i++) if(lasa%i==0 && lasa-i<L && lasa+i>R)
oka[i]=1;
}
}
else oka[A]=1;
if(B==0)
{
if(lasb==-1)
{
for(int i=1;i<L;i++) okb[i]=1;
for(int i=R+1;i<maxn;i++) okb[i]=1;
}
else
{
for(int i=1;i<maxn;i++) if(lasb%i==0 && lasb-i<L && lasb+i>R)
okb[i]=1;
}
}
else okb[B]=1;
if(AB==0)
{
if(lasab==-1)
{
for(int i=1;i<L;i++) okab[i]=1;
for(int i=R+1;i<maxn;i++) okab[i]=1;
}
else
{
for(int i=1;i<maxn;i++) if(lasab%i==0 && lasab-i<L && lasab+i>R)
okab[i]=1;
}
}
else okab[AB]=1;
for(int i=1;i<maxn;i++) if(oka[i])
{
for(int j=1;j<maxn;j++) if(okb[j])
{
int ij=i*j/gcd(i,j);
if(ij<maxn && okab[ij])
{
cout<<i<<' '<<j<<endl;
return 0;
}
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 5ms
memory: 13984kb
input:
7 11 7 8 Fizz Buzz 11
output:
3 5
result:
ok
Test #2:
score: 0
Accepted
time: 7ms
memory: 9820kb
input:
49999 50002 49999 FizzBuzz 50001 Fizz
output:
2 4
result:
ok
Test #3:
score: 0
Accepted
time: 7ms
memory: 11756kb
input:
8 11 Buzz Buzz FizzBuzz Buzz
output:
5 1
result:
ok
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 27240kb
input:
10 15 10 11 12 13 14 15
output:
1 1
result:
FAIL Mismatch at position 10: expected 10, got FizzBuzz