QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#365238 | #7111. Press the Button | shangtian | WA | 1ms | 3616kb | C++14 | 1.2kb | 2024-03-24 22:20:55 | 2024-03-24 22:20:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
const int mod=1e9+7;
void solved(){
int a,b,c,d,v,t;
cin>>a>>b>>c>>d>>v>>t;
int l=a*c/__gcd(a,c);
auto cal=[&](int mid){
int x=0;
int time=-1;
int t1=0,t2=0;
while(time<=mid){
if(min(t1*a,t2*c)>mid) break;
if(t1*a==t2*c){
if(time>=t1*a) x+=b+d;
else x+=b+d-1;
time=v+t1*a;
t1++,t2++;
}
else if(t1*a>t2*c){
if(time>=t2*c) x+=d;
else x+=d-1;
time=v+t2*c;
t2++;
}
else {
if(time>=t1*a) x+=b;
else x+=b-1;
time=v+a*t1;
t1++;
}
}
return make_pair(x,(time>=l?1:0));
};
if(t<l){
cout<<cal(t).first<<endl;
}
else{
auto [x,w]=cal(l-1);
auto [y,v]=cal(t%l);
cout<<(x+w)*(t/l)+y<<endl;
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
cin>>t;
while(t--){
solved();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3548kb
input:
2 8 2 5 1 2 18 10 2 5 1 2 10
output:
6 4
result:
ok 2 number(s): "6 4"
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3616kb
input:
1000 8 6 2 6 3 17 1 6 1 1 1 30 5 4 8 8 1 31 7 6 10 3 6 12 9 1 4 4 3 38 3 3 5 8 1 8 9 1 5 2 3 18 6 10 10 8 2 40 9 6 9 10 3 9 2 5 1 10 10 39 7 7 1 2 4 19 8 10 8 6 7 36 2 9 1 1 7 17 1 2 3 5 6 14 8 8 8 7 1 46 6 9 3 9 4 6 10 8 1 7 10 18 7 1 7 10 3 50 1 10 2 1 5 1 5 8 4 9 7 44 9 2 5 4 7 42 9 1 2 1 1 20 5 ...
output:
71 216 52 13 38 22 7 102 30 299 42 75 89 34 84 44 29 80 10 152 41 4 139 139 56 30 41 127 69 81 36 69 32 98 43 67 11 142 17 51 24 105 114 36 28 11 24 81 28 7 66 19 492 49 49 14 13 35 311 161 94 27 21 70 71 59 33 245 48 209 18 64 155 55 8 84 107 222 21 29 63 159 26 18 21 15 79 53 109 62 35 15 524 19 6...
result:
wrong answer 4th numbers differ - expected: '16', found: '13'