QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#606757 | #5553. Alternative Architecture | whale_island# | AC ✓ | 49ms | 3740kb | C++20 | 2.6kb | 2024-10-03 12:01:25 | 2024-10-03 12:01:27 |
Judging History
answer
// __________________
// | ________________ |
// || ____ ||
// || /\ | ||
// || /__\ | ||
// || / \ |____ ||
// ||________________||
// |__________________|
// \###################\
// \###################\
// \ ____ \
// \_______\___\_______\
// An AC a day keeps the doctor away.
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#define hutao_my_wife ios_base::sync_with_stdio(0);
#define forcalors_so_cute cin.tie(0);
/*
struct A {
public: [[nodiscard]] virtual const unsigned long long reference operator bitor (const unsigned long long reference a) const noexcept;
};
struct B: public A{
public: [[nodiscard]] virtual const unsigned long long reference operator bitor (const unsigned long long reference a) const noexcept override final {
}
};
inline char readchar() noexcept {
static char buffer[BUFSIZ], * now = buffer + BUFSIZ, * end = buffer + BUFSIZ;
if (now == end)
{
if (end < buffer + BUFSIZ)
return EOF;
end = (buffer + fread(buffer, 1, BUFSIZ, stdin));
now = buffer;
}
return *now++;
}
inline int nextint() noexcept {
int x = 0, c = readchar(), neg = 0;
while(('0' > c || c > '9') && c!='-' && c!=EOF) c = readchar();
if(c == '-') neg = true, c = readchar();
while('0' <= c && c <= '9') x = (x<<3) + (x<<1) + (c^'0'), c = readchar();
if(neg) x = -x;
return x; // returns 0 if EOF
}
//fast io cin>>a 改成 a = nextint();
*/
#define ll long long
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define ALL(v) v.begin(), v.end()
#define bug(A) cout<<A<<" hi\n";
using namespace std;
const ll M = 200005;
ll n,m;
ll deal(ll x){
ll ans = 0;
for(ll i = 1; i < n; i++){
ll l = 0, r = n, mid;
while(r - l > 1){
mid = (r + l)/2;
if(x*x - i*i > mid*mid)l = mid;
else r = mid;
}
if(r*r + i*i == x*x){
ans++;
// cout<<r<<' '<<i<<'\n';
}
//cout<<r<<' '<<i*i<<' '<<mid*mid<<'\n';
}
return ans;
}
void solve(){
cin>>n>>m;
n--,m--;
if(n>m)swap(n,m);
ll t1 = deal(__gcd(n,m));
//cout<<t1<<'\n';
if(n==m)cout<<t1 + 1<<'\n';
else cout<<t1*2 + 2<<'\n';
}
signed main(){
//
hutao_my_wife forcalors_so_cute
int t = 1;
//cin>>t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3684kb
input:
6 11
output:
6
result:
ok single line: '6'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
26 26
output:
5
result:
ok single line: '5'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
123 456
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
3 3
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
2 2
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
2 1000000
output:
2
result:
ok single line: '2'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
1000000 2
output:
2
result:
ok single line: '2'
Test #8:
score: 0
Accepted
time: 49ms
memory: 3680kb
input:
1000000 1000000
output:
9
result:
ok single line: '9'
Test #9:
score: 0
Accepted
time: 14ms
memory: 3736kb
input:
320451 480676
output:
270
result:
ok single line: '270'
Test #10:
score: 0
Accepted
time: 40ms
memory: 3668kb
input:
801126 801126
output:
189
result:
ok single line: '189'
Test #11:
score: 0
Accepted
time: 15ms
memory: 3664kb
input:
345451 460601
output:
10
result:
ok single line: '10'
Test #12:
score: 0
Accepted
time: 27ms
memory: 3608kb
input:
560236 560236
output:
63
result:
ok single line: '63'
Test #13:
score: 0
Accepted
time: 15ms
memory: 3668kb
input:
640901 320451
output:
270
result:
ok single line: '270'
Test #14:
score: 0
Accepted
time: 12ms
memory: 3692kb
input:
549251 274626
output:
98
result:
ok single line: '98'
Test #15:
score: 0
Accepted
time: 22ms
memory: 3684kb
input:
563551 751401
output:
150
result:
ok single line: '150'
Test #16:
score: 0
Accepted
time: 28ms
memory: 3672kb
input:
604251 906376
output:
42
result:
ok single line: '42'
Test #17:
score: 0
Accepted
time: 26ms
memory: 3664kb
input:
556251 834376
output:
66
result:
ok single line: '66'
Test #18:
score: 0
Accepted
time: 10ms
memory: 3740kb
input:
216051 216051
output:
45
result:
ok single line: '45'
Test #19:
score: 0
Accepted
time: 36ms
memory: 3732kb
input:
733526 733526
output:
135
result:
ok single line: '135'
Test #20:
score: 0
Accepted
time: 22ms
memory: 3672kb
input:
475307 950613
output:
54
result:
ok single line: '54'
Test #21:
score: 0
Accepted
time: 18ms
memory: 3684kb
input:
781251 390626
output:
34
result:
ok single line: '34'
Test #22:
score: 0
Accepted
time: 47ms
memory: 3668kb
input:
945051 945051
output:
45
result:
ok single line: '45'
Test #23:
score: 0
Accepted
time: 21ms
memory: 3684kb
input:
484201 564901
output:
30
result:
ok single line: '30'
Test #24:
score: 0
Accepted
time: 31ms
memory: 3600kb
input:
645961 645961
output:
9
result:
ok single line: '9'
Test #25:
score: 0
Accepted
time: 20ms
memory: 3668kb
input:
750621 450373
output:
6
result:
ok single line: '6'
Test #26:
score: 0
Accepted
time: 18ms
memory: 3608kb
input:
736951 368476
output:
70
result:
ok single line: '70'
Test #27:
score: 0
Accepted
time: 17ms
memory: 3684kb
input:
867603 433802
output:
18
result:
ok single line: '18'
Test #28:
score: 0
Accepted
time: 12ms
memory: 3616kb
input:
531251 265626
output:
78
result:
ok single line: '78'
Test #29:
score: 0
Accepted
time: 10ms
memory: 3604kb
input:
423501 211751
output:
14
result:
ok single line: '14'
Test #30:
score: 0
Accepted
time: 14ms
memory: 3612kb
input:
390626 390626
output:
17
result:
ok single line: '17'
Test #31:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
2 3
output:
2
result:
ok single line: '2'
Test #32:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
3 2
output:
2
result:
ok single line: '2'