QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#141508 | #5259. Skills in Pills | PhantomThreshold# | WA | 4ms | 3632kb | C++20 | 1.2kb | 2023-08-17 15:35:41 | 2023-08-17 15:35:43 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int a,int b){ return !a?b:gcd(b%a,a); }
const int inf = 3e6;
int n,A,B,ans;
int nex1,nex0;
signed main()
{
ios_base::sync_with_stdio(false);
cin>>A>>B>>n;
int d=gcd(A,B);
if(d!=1)
{
ans= n/A+ n/B;
ll lcm= 1LL*A*B/d;
if( lcm<=n && (n+1)%A==0 && (n+1)%B==0 ) ans++;
}
else
{
int tmpa=A,tmpb=B;
while( tmpa<inf && tmpb<inf && (nex1&nex0)==0 )
{
if(tmpa+1==tmpb && nex1==0) nex1=tmpa;
if(tmpa-1==tmpb && nex0==0) nex0=tmpa;
if(tmpa<tmpb) tmpa+=A;
else tmpb+=B;
}
if(nex0==0) nex0=inf;
if(nex1==0) nex1=inf;
// B A
int push= nex1<nex0 ? 1 : 0;
int use= (push==0)? (B-n%B-1) : (A-n%A-1);
tmpa=A,tmpb=B;
ans=2;
while( min(tmpa,tmpb)<=n )
{
if(tmpa<tmpb)
{
tmpa+=A;
if(tmpa<=n) ans++;
}
else
{
tmpb+=B;
if(tmpb<=n) ans++;
}
if(tmpa==tmpb)
{
if(use)
{
use--;
if(push==0) tmpb--;
else tmpa--;
}
else
{
if(push==0) tmpa--;
else tmpb--;
}
}
}
}
cout<<ans<<endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3464kb
input:
3 9 20
output:
8
result:
ok single line: '8'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3400kb
input:
8 2 12
output:
7
result:
ok single line: '7'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
2 5 15
output:
10
result:
ok single line: '10'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3428kb
input:
10 8 13
output:
2
result:
ok single line: '2'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3396kb
input:
6 6 19
output:
6
result:
ok single line: '6'
Test #6:
score: 0
Accepted
time: 4ms
memory: 3632kb
input:
2 3 5
output:
3
result:
ok single line: '3'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3408kb
input:
4 2 8
output:
6
result:
ok single line: '6'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
5 5 5
output:
2
result:
ok single line: '2'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
3 8 11
output:
4
result:
ok single line: '4'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
5 8 16
output:
5
result:
ok single line: '5'
Test #11:
score: 0
Accepted
time: 2ms
memory: 3484kb
input:
9 7 279
output:
70
result:
ok single line: '70'
Test #12:
score: 0
Accepted
time: 3ms
memory: 3448kb
input:
8 3 56
output:
25
result:
ok single line: '25'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
5 9 46
output:
14
result:
ok single line: '14'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
8 4 251
output:
93
result:
ok single line: '93'
Test #15:
score: 0
Accepted
time: 2ms
memory: 3376kb
input:
8 7 41
output:
10
result:
ok single line: '10'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3464kb
input:
60 17 360
output:
27
result:
ok single line: '27'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3464kb
input:
16 55 388
output:
31
result:
ok single line: '31'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3484kb
input:
25 38 292
output:
18
result:
ok single line: '18'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
22 59 177
output:
11
result:
ok single line: '11'
Test #20:
score: -100
Wrong Answer
time: 3ms
memory: 3576kb
input:
4 3 82
output:
52
result:
wrong answer 1st lines differ - expected: '50', found: '52'