QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#763472#6607. Rise of ShadowsAmiyaCast#WA 27ms3872kbC++202.6kb2024-11-19 20:27:462024-11-19 20:27:47

Judging History

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

  • [2024-11-19 20:27:47]
  • 评测
  • 测评结果:WA
  • 用时:27ms
  • 内存:3872kb
  • [2024-11-19 20:27:46]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define pii pair<ll, ll>
const ll inf = 2e18;
const double eps = 1e-9;
using namespace std;
const int STD = 1000000;
// const int STD = 2;
const int CNT = 1e6;
void slv(){
    ll h, m, a, ans = 0;
    cin >> h >> m >> a;

    ll lst = 0;
    if(h <= STD) {
        for(ll i = 0; i < h - 1; ++i) {
            ans += floor((m * i + 0.0 + a) / (h - 1 + 0.0)) - ceil((m * i + 0.0 - a) / (h - 1 + 0.0)) + 1;
            lst = ans;
        }
        cout << ans << endl;
    } else {
        function <ll(void)> calc1 = [&]() {
            function <ll(ll, ll) > calc = [&](ll x, ll y) {
                return max(0ll, min(h - 2, y) - max(0ll, x) + 1);
            };

            function <ll(ll)> getl = [&](ll k) {
                if((k * (h - 1) - a) % m == 0) {
                    return (k * (h - 1) - a) / m;
                } else {
                    return (k * (h - 1) - a) / m + 1;
                }
            };

            function <ll(ll)> getr = [&](ll k) {
                if(((k + 1) * (h - 1) - a) % m == 0) {
                    return ((k + 1) * (h - 1) - a) / m - 1;
                } else {
                    return ((k + 1) * (h - 1) - a) / m;
                }
            };

            ll tmp = 0;
            for(ll i = 1; i < CNT; ++i) {
                tmp += i * calc(getl(i), getr(i));
            }
            return tmp;
        };

        function <ll(void)> calc2 = [&]() {
            function <ll(ll, ll)> div = [&](ll x, ll y) {
                if(x > 0) {
                    return x / y;
                } else {
                    if(x % y == 0) {
                        return x / y;
                    } else {
                        return x / y - 1;
                    }
                }
            };

            function <ll(ll, ll) > calc = [&](ll x, ll y) {
                return max(0ll, min(h - 2, y) - max(0ll, x) + 1);
            };

            function <ll(ll)> getl = [&](ll k) {
                return div(((k - 1) * (h - 1) + a),  m) + 1;
            };

            function <ll(ll)> getr = [&](ll k) {
                return div((k * (h - 1) + a), m);
            };

            ll tmp = 0;
            for(ll i = -CNT; i < CNT; ++i) {
                if(i == 0) continue;
                tmp += i * calc(getl(i), getr(i));
            }
            return tmp;
        };

        cout << calc1() - calc2() + (h - 1) << endl;
    }
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    int _ = 1;
    //cin >> _;
    while(_--) slv();
    return 0;
}

详细

Test #1:

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

input:

5 5 4

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

3 5 1

output:

3

result:

ok 1 number(s): "3"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

5 5 0

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

5 5 1

output:

3

result:

ok 1 number(s): "3"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

5 5 2

output:

5

result:

ok 1 number(s): "5"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

5 5 3

output:

7

result:

ok 1 number(s): "7"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

5 5 5

output:

11

result:

ok 1 number(s): "11"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

5 5 6

output:

13

result:

ok 1 number(s): "13"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

5 5 7

output:

15

result:

ok 1 number(s): "15"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

5 5 8

output:

17

result:

ok 1 number(s): "17"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

5 5 9

output:

19

result:

ok 1 number(s): "19"

Test #12:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

5 5 10

output:

21

result:

ok 1 number(s): "21"

Test #13:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

5 5 11

output:

23

result:

ok 1 number(s): "23"

Test #14:

score: -100
Wrong Answer
time: 27ms
memory: 3516kb

input:

628383665 981360590 38277030565242771

output:

628568854

result:

wrong answer 1st numbers differ - expected: '76554061130485542', found: '628568854'