QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#592840#5553. Alternative Architectureship2077AC ✓4ms3932kbC++23842b2024-09-27 08:46:162024-09-27 08:46:17

Judging History

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

  • [2024-09-27 08:46:17]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:3932kb
  • [2024-09-27 08:46:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int>>vec1,vec2;
int n,m,ans;long long n2,m2;
int main(){
    scanf("%d%d",&n,&m);n--;m--;
    n2=1ll*n*n;m2=1ll*m*m;
    for (int i=1;i<n;i++){
        int j=sqrt(n2-1ll*i*i);
        if (1ll*i*i+1ll*j*j==n2)
            vec1.emplace_back(i,j);
    }
    for (int i=1;i<m;i++){
        int j=sqrt(m2-1ll*i*i);
        if (1ll*i*i+1ll*j*j==m2)
            vec2.emplace_back(i,j);
    }
    while (!vec1.empty()&&!vec2.empty()){
        long long res1=1ll*vec1.back().first*vec2.back().second,
                  res2=1ll*vec2.back().first*vec1.back().second;
        if (res1>res2) vec1.pop_back();
        else if (res1<res2) vec2.pop_back();
        else ans++,vec1.pop_back(),vec2.pop_back();
    }
    printf("%d\n",n==m?ans+1:ans+1<<1);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 11

output:

6

result:

ok single line: '6'

Test #2:

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

input:

26 26

output:

5

result:

ok single line: '5'

Test #3:

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

input:

123 456

output:

2

result:

ok single line: '2'

Test #4:

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

input:

3 3

output:

1

result:

ok single line: '1'

Test #5:

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

input:

2 2

output:

1

result:

ok single line: '1'

Test #6:

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

input:

2 1000000

output:

2

result:

ok single line: '2'

Test #7:

score: 0
Accepted
time: 3ms
memory: 3860kb

input:

1000000 2

output:

2

result:

ok single line: '2'

Test #8:

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

input:

1000000 1000000

output:

9

result:

ok single line: '9'

Test #9:

score: 0
Accepted
time: 2ms
memory: 3796kb

input:

320451 480676

output:

270

result:

ok single line: '270'

Test #10:

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

input:

801126 801126

output:

189

result:

ok single line: '189'

Test #11:

score: 0
Accepted
time: 2ms
memory: 3868kb

input:

345451 460601

output:

10

result:

ok single line: '10'

Test #12:

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

input:

560236 560236

output:

63

result:

ok single line: '63'

Test #13:

score: 0
Accepted
time: 2ms
memory: 3832kb

input:

640901 320451

output:

270

result:

ok single line: '270'

Test #14:

score: 0
Accepted
time: 2ms
memory: 3732kb

input:

549251 274626

output:

98

result:

ok single line: '98'

Test #15:

score: 0
Accepted
time: 3ms
memory: 3824kb

input:

563551 751401

output:

150

result:

ok single line: '150'

Test #16:

score: 0
Accepted
time: 3ms
memory: 3824kb

input:

604251 906376

output:

42

result:

ok single line: '42'

Test #17:

score: 0
Accepted
time: 3ms
memory: 3796kb

input:

556251 834376

output:

66

result:

ok single line: '66'

Test #18:

score: 0
Accepted
time: 1ms
memory: 3740kb

input:

216051 216051

output:

45

result:

ok single line: '45'

Test #19:

score: 0
Accepted
time: 3ms
memory: 3796kb

input:

733526 733526

output:

135

result:

ok single line: '135'

Test #20:

score: 0
Accepted
time: 3ms
memory: 3932kb

input:

475307 950613

output:

54

result:

ok single line: '54'

Test #21:

score: 0
Accepted
time: 2ms
memory: 3728kb

input:

781251 390626

output:

34

result:

ok single line: '34'

Test #22:

score: 0
Accepted
time: 4ms
memory: 3784kb

input:

945051 945051

output:

45

result:

ok single line: '45'

Test #23:

score: 0
Accepted
time: 2ms
memory: 3820kb

input:

484201 564901

output:

30

result:

ok single line: '30'

Test #24:

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

input:

645961 645961

output:

9

result:

ok single line: '9'

Test #25:

score: 0
Accepted
time: 2ms
memory: 3728kb

input:

750621 450373

output:

6

result:

ok single line: '6'

Test #26:

score: 0
Accepted
time: 2ms
memory: 3740kb

input:

736951 368476

output:

70

result:

ok single line: '70'

Test #27:

score: 0
Accepted
time: 3ms
memory: 3848kb

input:

867603 433802

output:

18

result:

ok single line: '18'

Test #28:

score: 0
Accepted
time: 2ms
memory: 3928kb

input:

531251 265626

output:

78

result:

ok single line: '78'

Test #29:

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

input:

423501 211751

output:

14

result:

ok single line: '14'

Test #30:

score: 0
Accepted
time: 2ms
memory: 3884kb

input:

390626 390626

output:

17

result:

ok single line: '17'

Test #31:

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

input:

2 3

output:

2

result:

ok single line: '2'

Test #32:

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

input:

3 2

output:

2

result:

ok single line: '2'