QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#303863#7111. Press the Buttonkevinshan#WA 1ms3628kbC++172.2kb2024-01-13 02:47:562024-01-13 02:47:57

Judging History

你现在查看的是最新测评结果

  • [2024-01-13 02:47:57]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3628kb
  • [2024-01-13 02:47:56]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define ps push
#define in insert
#define f first
#define s second
#define nl cout<<"\n"
#define ca(v) for(auto i:v) cout<<i<<" ";
#define cbit(x) __builtin_popcount(x)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a*b/gcd(a, b))
const int xm[4] = {-1, 1, 0, 0};
const int ym[4] = {0, 0, -1, 1};
const int MOD = 1e9 + 7;
const int MAXN = 5e5 + 5;
const ll POW = 9973;

pair<ll, ll> eval(ll a, ll b, ll c, ll d, ll v, ll t){
    ll cnt = b + d - 1;
    ll last = 0;
    ll x = a;
    ll y = c;
    while(x <= t || y <= t){
        if(x < y){
            if(last + v < x) cnt -= 1;
            last = x;
            x += a;
            cnt += b;
        } else {
            if(last + v < y) cnt -= 1;
            last = y;
            y += c;
            cnt += d;
        }
    }
    return {cnt, last};
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int T; cin>>T;
    while(T--){
        ll a, b, c, d, v, t;
        cin>>a>>b>>c>>d>>v>>t;
        ll tot = 0;
        if(t % (a * c) == 0){
            ll rep = t / (a * c);
            auto fullres = eval(a,b,c,d,v,a*b-1);
            if(fullres.s + v >= a * c) {
                tot += rep * fullres.f + rep - 1;
                tot += b * d;
            } else {
                tot += rep * fullres.f;
                tot += b * d - 1;
            }
        }
        else if(a * c > t){
            ll rep = t / (a * c);
            ll res = t % (a * c);
            auto fullres = eval(a,b,c,d,v,a*c-1);
            if(fullres.s + v >= a * c) {
                tot += rep * fullres.f + rep - 1;
                tot += eval(a, b, c, d, v, res).f + 1;
            } else {
                tot += rep * fullres.f;
                tot += eval(a, b, c, d, v, res).f;
            }
        }
        else if(a * b < t){
            tot += eval(a, b, c, d, v, t).f;
        }
        cout<<tot<<"\n";
    }

}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3584kb

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: 3628kb

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:

0
1265
52
16
38
22
7
102
30
499
0
75
0
54
84
44
0
80
20
179
45
4
2294
0
0
30
45
127
204
121
42
69
38
98
63
121
25
0
17
0
24
175
114
40
32
11
29
85
35
7
66
49
4355
114
49
14
17
53
371
80
94
27
21
0
118
92
33
442
57
1108
18
89
0
55
10
219
223
390
28
50
67
213
26
18
27
19
128
101
118
0
46
15
5149
20
80...

result:

wrong answer 1st numbers differ - expected: '71', found: '0'