QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#293924 | #5259. Skills in Pills | LaStataleBlue# | WA | 1ms | 3492kb | C++23 | 1.5kb | 2023-12-29 23:03:22 | 2023-12-29 23:03:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void solve(int t){
int k,j,n;
cin>>k>>j>>n;
int lcm = k*j/__gcd(k,j);
if(k<j)swap(k,j);
int res=1e7;
for(int st=max(1,k-100);st<=k;st++){
for(int st2=max(1,j-100);st2<=j;st2++){
for(int par=0;par<2;par++){
int ans=0;
int pos1=st,pos2=st2;
int cont=0;
while(pos1<=n || pos2<=n){
if(pos1<pos2){
ans++;
pos1+=k;
}else if(pos2<pos1){
ans++;
pos2+=j;
}else{
ans+=2;
if(par==3)pos1--;
else if(par==4)pos2--;
else if(cont%2==par){
pos1--;
}else{
pos2--;
}
cont++;
pos1+=k;
pos2+=j;
}
}
res=min(ans,res);
}
//cout<<ans<<"\n";
}
}
cout<<res<<"\n";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)solve(i);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3392kb
input:
3 9 20
output:
8
result:
ok single line: '8'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3492kb
input:
8 2 12
output:
7
result:
ok single line: '7'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3384kb
input:
2 5 15
output:
11
result:
wrong answer 1st lines differ - expected: '10', found: '11'