QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#461811 | #5553. Alternative Architecture | WeaRD276 | WA | 1ms | 3668kb | C++20 | 1.6kb | 2024-07-03 02:39:01 | 2024-07-03 02:39:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<long long, long long>> vpll;
typedef set<int> si;
typedef set<long long> sll;
typedef map<int, int> mii;
typedef map<long long, long long> mll;
constexpr int INF = 1e9 + 47;
constexpr long long LINF = (ll)1e18 + 4747;
constexpr int MOD = 998244353;
constexpr int N = 1e6 + 47;
pii check(ll a)
{
a--;
a *= a;
for (ll i = 1; i < sqrt(a) + 1; i++)
{
ll sec = a - i * i;
sec = sqrt(sec);
if (i * i + sec * sec == a && i != sec && sec != 0)
return MP(i, sec);
sec--;
if (i * i + sec * sec == a && i != sec && sec != 0)
return MP(i, sec);
sec += 2;
if (i * i + sec * sec == a && i != sec && sec != 0)
return MP(i, sec);
}
return {0, 0};
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
ll a, b;
cin >> a >> b;
int ans = 1 + (a != b);
if (a > b)
swap(a, b);
pii p1 = check(a);
pii p2 = check(b);
if (p1.F != 0 && p2.F != 0 && p2.F % p1.F == 0 && p2.S % p1.S == 0 && p2.F / p1.F == p2.S / p1.S)
ans += 4;
cout << ans << '\n';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3532kb
input:
6 11
output:
6
result:
ok single line: '6'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3604kb
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: 1ms
memory: 3560kb
input:
3 3
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
2 2
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
2 1000000
output:
2
result:
ok single line: '2'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3452kb
input:
1000000 2
output:
2
result:
ok single line: '2'
Test #8:
score: -100
Wrong Answer
time: 1ms
memory: 3628kb
input:
1000000 1000000
output:
5
result:
wrong answer 1st lines differ - expected: '9', found: '5'