QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#656058#6607. Rise of Shadowscrush_codemaker#WA 0ms3956kbC++14914b2024-10-19 11:07:162024-10-19 11:07:16

Judging History

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

  • [2024-10-19 11:07:16]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3956kb
  • [2024-10-19 11:07:16]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define N 200007
#pragma GCC optimize(2)
using namespace std;
int H,M,A;
int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}
int zc(int a,int b,int c)
{
    int g=gcd(a,c),x=((b%c+c)%c)%g;
    int t=(c-1-x)/g;
    if(x==0)
    {
        return c/(t+1);
    }
    return 0;
}
int cal1(int a,int b,int c)
{
    int g=gcd(a,c),x=((b%c+c)%c)%g;
    int t=(c-1-x)/g;
    int ans=(x+x+t*g)*(t+1)/2*(c/(t+1));
    return ans;
}
int cal2(int a,int b,int c)
{
    return (b+(c-1)*a+b)*c/2;
}
int down(int a,int b,int c)
{
    return (cal2(a,b,c)-cal1(a,b,c))/c;
}
int up(int a,int b,int c)
{
    return (cal2(a,b,c)+c*(c-zc(a,b,c))-cal1(a,b,c))/c;
}
void solve()
{
    scanf("%lld%lld%lld",&H,&M,&A);
    int ans=down(H*M,A,H-1)-up(H*M,-A,H-1)+(H-1);
    printf("%lld\n",ans);
}
signed main()
{
    solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 5 4

output:

9

result:

ok 1 number(s): "9"

Test #2:

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

input:

3 5 1

output:

3

result:

ok 1 number(s): "3"

Test #3:

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

input:

5 5 0

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

5 5 1

output:

3

result:

ok 1 number(s): "3"

Test #5:

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

input:

5 5 2

output:

5

result:

ok 1 number(s): "5"

Test #6:

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

input:

5 5 3

output:

7

result:

ok 1 number(s): "7"

Test #7:

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

input:

5 5 5

output:

11

result:

ok 1 number(s): "11"

Test #8:

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

input:

5 5 6

output:

13

result:

ok 1 number(s): "13"

Test #9:

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

input:

5 5 7

output:

15

result:

ok 1 number(s): "15"

Test #10:

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

input:

5 5 8

output:

17

result:

ok 1 number(s): "17"

Test #11:

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

input:

5 5 9

output:

19

result:

ok 1 number(s): "19"

Test #12:

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

input:

5 5 10

output:

21

result:

ok 1 number(s): "21"

Test #13:

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

input:

5 5 11

output:

23

result:

ok 1 number(s): "23"

Test #14:

score: -100
Wrong Answer
time: 0ms
memory: 3816kb

input:

628383665 981360590 38277030565242771

output:

5870501311

result:

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