QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#373724 | #5553. Alternative Architecture | kevinyang# | AC ✓ | 60ms | 3700kb | C++17 | 1.8kb | 2024-04-02 02:11:07 | 2024-04-02 02:11:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
typedef Point P;
T x, y;
explicit Point(T x=0, T y=0) : x(x), y(y) {}
bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
P operator+(P p) const { return P(x+p.x, y+p.y); }
P operator-(P p) const { return P(x-p.x, y-p.y); }
P operator*(T d) const { return P(x*d, y*d); }
P operator/(T d) const { return P(x/d, y/d); }
T dot(P p) const { return x*p.x + y*p.y; }
T cross(P p) const { return x*p.y - y*p.x; }
T cross(P a, P b) const { return (a-*this).cross(b-*this); }
T dist2() const { return x*x + y*y; }
double dist() const { return sqrt((double)dist2()); }
// angle to x-axis in interval [-pi, pi]
double angle() const { return atan2(y, x); }
P unit() const { return *this/dist(); } // makes dist()=1
P perp() const { return P(-y, x); } // rotates +90 degrees
P normal() const { return perp().unit(); }
// returns point rotated 'a' radians ccw around the origin
P rotate(double a) const {
return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
friend ostream& operator<<(ostream& os, P p) {
return os << "(" << p.x << "," << p.y << ")"; }
};
int sq(int x){
int low = 0; int high = (int)1e9;
while(low + 1 < high){
int mid = (low+high)/2;
if(mid*mid<=x){
low = mid;
}
else{
high = mid;
}
}
return low;
}
signed main(){
cin.tie(nullptr)->sync_with_stdio(false);
int a,b;
cin >> a >> b;
a--; b--;
if(a>b)swap(a,b);
int ans = 1;
int x = __gcd(a,b);
for(int i = 1; i<x; i++){
int v = sq(x*x-i*i);
if(v*v + i*i==x*x){
ans++;
}
}
if(a!=b)
cout << ans*2 << '\n';
else cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3700kb
input:
6 11
output:
6
result:
ok single line: '6'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
26 26
output:
5
result:
ok single line: '5'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
123 456
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
3 3
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
2 2
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
2 1000000
output:
2
result:
ok single line: '2'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
1000000 2
output:
2
result:
ok single line: '2'
Test #8:
score: 0
Accepted
time: 60ms
memory: 3656kb
input:
1000000 1000000
output:
9
result:
ok single line: '9'
Test #9:
score: 0
Accepted
time: 10ms
memory: 3608kb
input:
320451 480676
output:
270
result:
ok single line: '270'
Test #10:
score: 0
Accepted
time: 48ms
memory: 3612kb
input:
801126 801126
output:
189
result:
ok single line: '189'
Test #11:
score: 0
Accepted
time: 7ms
memory: 3616kb
input:
345451 460601
output:
10
result:
ok single line: '10'
Test #12:
score: 0
Accepted
time: 34ms
memory: 3672kb
input:
560236 560236
output:
63
result:
ok single line: '63'
Test #13:
score: 0
Accepted
time: 16ms
memory: 3656kb
input:
640901 320451
output:
270
result:
ok single line: '270'
Test #14:
score: 0
Accepted
time: 17ms
memory: 3560kb
input:
549251 274626
output:
98
result:
ok single line: '98'
Test #15:
score: 0
Accepted
time: 12ms
memory: 3616kb
input:
563551 751401
output:
150
result:
ok single line: '150'
Test #16:
score: 0
Accepted
time: 15ms
memory: 3656kb
input:
604251 906376
output:
42
result:
ok single line: '42'
Test #17:
score: 0
Accepted
time: 17ms
memory: 3616kb
input:
556251 834376
output:
66
result:
ok single line: '66'
Test #18:
score: 0
Accepted
time: 14ms
memory: 3564kb
input:
216051 216051
output:
45
result:
ok single line: '45'
Test #19:
score: 0
Accepted
time: 44ms
memory: 3644kb
input:
733526 733526
output:
135
result:
ok single line: '135'
Test #20:
score: 0
Accepted
time: 29ms
memory: 3652kb
input:
475307 950613
output:
54
result:
ok single line: '54'
Test #21:
score: 0
Accepted
time: 23ms
memory: 3644kb
input:
781251 390626
output:
34
result:
ok single line: '34'
Test #22:
score: 0
Accepted
time: 53ms
memory: 3656kb
input:
945051 945051
output:
45
result:
ok single line: '45'
Test #23:
score: 0
Accepted
time: 6ms
memory: 3568kb
input:
484201 564901
output:
30
result:
ok single line: '30'
Test #24:
score: 0
Accepted
time: 39ms
memory: 3612kb
input:
645961 645961
output:
9
result:
ok single line: '9'
Test #25:
score: 0
Accepted
time: 10ms
memory: 3616kb
input:
750621 450373
output:
6
result:
ok single line: '6'
Test #26:
score: 0
Accepted
time: 23ms
memory: 3548kb
input:
736951 368476
output:
70
result:
ok single line: '70'
Test #27:
score: 0
Accepted
time: 23ms
memory: 3668kb
input:
867603 433802
output:
18
result:
ok single line: '18'
Test #28:
score: 0
Accepted
time: 18ms
memory: 3604kb
input:
531251 265626
output:
78
result:
ok single line: '78'
Test #29:
score: 0
Accepted
time: 14ms
memory: 3624kb
input:
423501 211751
output:
14
result:
ok single line: '14'
Test #30:
score: 0
Accepted
time: 24ms
memory: 3700kb
input:
390626 390626
output:
17
result:
ok single line: '17'
Test #31:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
2 3
output:
2
result:
ok single line: '2'
Test #32:
score: 0
Accepted
time: 1ms
memory: 3608kb
input:
3 2
output:
2
result:
ok single line: '2'