QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#201312 | #5158. Interview Question | PhantomThreshold# | WA | 10ms | 27448kb | C++20 | 1.8kb | 2023-10-05 13:40:38 | 2023-10-05 13:40:38 |
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++)
{
if( (R/i*i)<L )
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++)
{
if( (R/i*i)<L )
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++)
{
if( (R/i*i)<L )
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: 8ms
memory: 13884kb
input:
7 11 7 8 Fizz Buzz 11
output:
3 5
result:
ok
Test #2:
score: 0
Accepted
time: 3ms
memory: 7960kb
input:
49999 50002 49999 FizzBuzz 50001 Fizz
output:
2 4
result:
ok
Test #3:
score: 0
Accepted
time: 7ms
memory: 9680kb
input:
8 11 Buzz Buzz FizzBuzz Buzz
output:
5 1
result:
ok
Test #4:
score: 0
Accepted
time: 5ms
memory: 27204kb
input:
10 15 10 11 12 13 14 15
output:
8 8
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 27288kb
input:
17 17 17
output:
2 2
result:
ok
Test #6:
score: 0
Accepted
time: 3ms
memory: 23484kb
input:
13 13 Fizz
output:
1 2
result:
ok
Test #7:
score: 0
Accepted
time: 6ms
memory: 23192kb
input:
20 20 Buzz
output:
3 1
result:
ok
Test #8:
score: 0
Accepted
time: 10ms
memory: 14016kb
input:
30 30 FizzBuzz
output:
1 1
result:
ok
Test #9:
score: 0
Accepted
time: 7ms
memory: 9768kb
input:
9 10 Buzz FizzBuzz
output:
2 1
result:
ok
Test #10:
score: 0
Accepted
time: 10ms
memory: 7852kb
input:
2 6 2 3 4 5 FizzBuzz
output:
6 6
result:
ok
Test #11:
score: 0
Accepted
time: 7ms
memory: 21952kb
input:
6 7 Fizz 7
output:
2 4
result:
ok
Test #12:
score: 0
Accepted
time: 3ms
memory: 23192kb
input:
7 8 Buzz Buzz
output:
3 1
result:
ok
Test #13:
score: 0
Accepted
time: 0ms
memory: 21064kb
input:
4 8 4 5 Buzz 7 8
output:
9 3
result:
ok
Test #14:
score: 0
Accepted
time: 1ms
memory: 9768kb
input:
33 50 Buzz 34 35 FizzBuzz 37 38 Buzz 40 41 FizzBuzz 43 44 Buzz 46 47 FizzBuzz 49 50
output:
6 3
result:
ok
Test #15:
score: 0
Accepted
time: 1ms
memory: 7660kb
input:
32 47 32 33 34 35 FizzBuzz 37 38 39 40 41 FizzBuzz 43 44 45 46 47
output:
6 6
result:
ok
Test #16:
score: 0
Accepted
time: 1ms
memory: 7884kb
input:
9 72 9 FizzBuzz 11 12 13 14 15 16 17 18 19 FizzBuzz 21 22 23 24 25 26 27 28 29 FizzBuzz 31 32 33 34 35 36 37 38 39 FizzBuzz 41 42 43 44 45 46 47 48 49 FizzBuzz 51 52 53 54 55 56 57 58 59 FizzBuzz 61 62 63 64 65 66 67 68 69 FizzBuzz 71 72
output:
10 10
result:
ok
Test #17:
score: 0
Accepted
time: 3ms
memory: 20316kb
input:
55 59 55 Fizz 57 Fizz 59
output:
2 6
result:
ok
Test #18:
score: 0
Accepted
time: 0ms
memory: 9708kb
input:
35 65 Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz FizzBuzz Fizz
output:
1 2
result:
ok
Test #19:
score: 0
Accepted
time: 0ms
memory: 27208kb
input:
3 6 3 4 5 6
output:
7 7
result:
ok
Test #20:
score: 0
Accepted
time: 0ms
memory: 27228kb
input:
4 5 4 5
output:
3 3
result:
ok
Test #21:
score: 0
Accepted
time: 0ms
memory: 27288kb
input:
3 10 3 4 5 6 7 8 9 10
output:
11 11
result:
ok
Test #22:
score: 0
Accepted
time: 0ms
memory: 27200kb
input:
2 4 2 3 4
output:
5 5
result:
ok
Test #23:
score: 0
Accepted
time: 0ms
memory: 27284kb
input:
3 4 3 4
output:
5 5
result:
ok
Test #24:
score: 0
Accepted
time: 0ms
memory: 27448kb
input:
1 67 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
output:
68 68
result:
ok
Test #25:
score: 0
Accepted
time: 3ms
memory: 13868kb
input:
45 73 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 Fizz 61 62 63 64 65 66 67 68 69 70 71 Buzz 73
output:
20 36
result:
ok
Test #26:
score: 0
Accepted
time: 0ms
memory: 19980kb
input:
23 85 23 Fizz 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 Fizz 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 Fizz 73 74 75 76 77 78 79 80 81 82 83 84 85
output:
24 86
result:
ok
Test #27:
score: 0
Accepted
time: 2ms
memory: 27260kb
input:
2 3 2 3
output:
4 4
result:
ok
Test #28:
score: 0
Accepted
time: 2ms
memory: 14052kb
input:
8 64 8 9 10 Buzz 12 13 14 15 16 17 18 19 20 21 Buzz 23 24 25 26 27 28 29 30 31 32 Buzz 34 35 36 37 38 39 40 41 42 43 Buzz 45 46 47 48 49 Fizz 51 52 53 54 Buzz 56 57 58 59 60 61 62 63 64
output:
50 11
result:
ok
Test #29:
score: 0
Accepted
time: 6ms
memory: 21812kb
input:
5 8 Fizz 6 7 8
output:
5 9
result:
ok
Test #30:
score: 0
Accepted
time: 3ms
memory: 20740kb
input:
1 7 1 2 3 Fizz 5 6 7
output:
4 8
result:
ok
Test #31:
score: -100
Wrong Answer
time: 0ms
memory: 14452kb
input:
1 100000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...
output:
result:
wrong output format Unexpected end of file - int32 expected