QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#409947 | #8111. Coaches | Dinal | WA | 4ms | 3776kb | C++14 | 558b | 2024-05-12 22:48:30 | 2024-05-12 22:48:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b;
ll solve1(ll x,ll y,ll z,ll r){
}
ll solve2(ll x,ll y,ll z,ll r){
for(int k=0;k<z;++k)
if((x+k*y)%z>=r)
return x+k*y;
return 2e18;
}
void reimu_main(){
cin>>n>>a>>b;
ll l=a*b/__gcd(a,b);
ll ra=n%a,rb=n%b,rl=n%l;
ll sx=n/a+n/b-n/l*2;
ll sy=(min(ra,rb)<rl);
if(solve2((n-1)%a+1,a,b,(n-1)%b+1)<rl)sy=2;
if(solve2((n-1)%b+1,b,a,(n-1)%a+1)<rl)sy=2;
printf("%lld\n",n-sx+sy);
}
int main(){
int T;cin>>T;
while(T--)reimu_main();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3680kb
input:
2 5 2 3 10 7 2
output:
3 6
result:
ok 2 number(s): "3 6"
Test #2:
score: -100
Wrong Answer
time: 4ms
memory: 3776kb
input:
1728 7 6 3 10 12 1 6 2 7 8 4 10 11 10 5 1 6 8 3 3 5 9 2 6 11 1 5 1 1 8 7 3 6 6 10 9 2 1 7 3 4 7 8 3 4 4 5 9 9 4 3 6 2 8 11 4 1 6 8 4 11 1 8 9 11 2 9 6 1 5 3 8 7 1 8 7 11 12 3 9 1 2 12 6 7 2 6 5 11 10 9 5 3 3 6 2 7 5 5 12 4 3 7 8 2 8 11 11 10 1 10 5 1 7 9 1 7 8 1 6 8 4 6 5 5 11 12 3 7 3 6 8 6 3 11 6 ...
output:
6 1 4 7 10 1 3 7 3 1 6 6 1 3 5 4 6 4 3 6 2 6 2 5 1 7 1 2 5 5 6 3 7 7 5 8 1 1 2 2 7 5 9 3 5 4 11 3 1 1 12 3 7 1 5 5 12 2 10 1 9 5 1 2 10 6 3 12 1 12 9 6 1 7 2 5 10 7 11 9 2 3 1 6 9 8 2 5 3 3 10 1 8 11 2 8 8 7 7 9 3 1 2 3 1 3 3 9 4 6 8 1 12 6 3 10 1 1 9 12 6 1 9 10 1 5 2 3 12 7 6 6 9 10 9 1 2 5 2 4 4 ...
result:
wrong answer 15th numbers differ - expected: '6', found: '5'