QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#763484#6607. Rise of ShadowsAmiyaCast#WA 61ms3792kbC++203.0kb2024-11-19 20:34:232024-11-19 20:34:23

Judging History

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

  • [2024-11-19 20:34:23]
  • 评测
  • 测评结果:WA
  • 用时:61ms
  • 内存:3792kb
  • [2024-11-19 20:34:23]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define ll __int128
#define pii pair<ll, ll>
const ll inf = 2e18;
const double eps = 1e-9;
using namespace std;
const int STD = 1e6;
// const int STD = 2;
const int CNT = 1e6;
inline ll read() {
	ll x=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9') {
		if (c=='-')  f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
inline void print(ll x) {
	if(x < 0) putchar('-'), x = -x;
	if(x > 9) print(x / 10);
	putchar(x % 10 + '0');
	return ;
}

inline void pprint(ll x) {
	print(x);
	puts("");
}
__int128 zero = 0;
void slv(){
    ll h, m, a, ans = 0;
    h = read(), m = read(), a = read();

    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;
        }
        pprint(ans);
    } else {
        function <ll(void)> calc1 = [&]() {
            function <ll(ll, ll) > calc = [&](ll x, ll y) {
                return max(zero, min(h - 2, y) - max(zero, 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(zero, min(h - 2, y) - max(zero, 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;
        };

        pprint(calc1() - calc2() + (h - 1));
    }
}

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

input:

5 5 4

output:

9

result:

ok 1 number(s): "9"

Test #2:

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

input:

3 5 1

output:

3

result:

ok 1 number(s): "3"

Test #3:

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

input:

5 5 0

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

5 5 1

output:

3

result:

ok 1 number(s): "3"

Test #5:

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

input:

5 5 2

output:

5

result:

ok 1 number(s): "5"

Test #6:

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

input:

5 5 3

output:

7

result:

ok 1 number(s): "7"

Test #7:

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

input:

5 5 5

output:

11

result:

ok 1 number(s): "11"

Test #8:

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

input:

5 5 6

output:

13

result:

ok 1 number(s): "13"

Test #9:

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

input:

5 5 7

output:

15

result:

ok 1 number(s): "15"

Test #10:

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

input:

5 5 8

output:

17

result:

ok 1 number(s): "17"

Test #11:

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

input:

5 5 9

output:

19

result:

ok 1 number(s): "19"

Test #12:

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

input:

5 5 10

output:

21

result:

ok 1 number(s): "21"

Test #13:

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

input:

5 5 11

output:

23

result:

ok 1 number(s): "23"

Test #14:

score: -100
Wrong Answer
time: 61ms
memory: 3592kb

input:

628383665 981360590 38277030565242771

output:

628568854

result:

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