QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#318815 | #4640. 反正切函数的应用 | plmlees | 100 ✓ | 1ms | 3940kb | C++14 | 571b | 2024-01-31 21:14:09 | 2024-01-31 21:14:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define fo(v, a, b) for(int v = a; v <= b; v++)
#define fr(v, a, b) for(int v = a; v >= b; v--)
#define cl(a, v) memset(a, v, sizeof(a))
typedef long long ll;
int a; ll z, ans = (ll)1e18;
void check(ll x) {
ll c = x + a, b = (a * c + 1) / (c - a);
assert(a * (b + c) == b * c - 1);
ans = min(ans, b + c);
}
int main()
{
scanf("%d", &a), z = (ll)a * a + 1;
for(ll i = 1; i * i <= z; i++) if(z % i == 0)
check(i), check(z / i);
printf("%lld\n", ans);
return 0;
}
详细
Test #1:
score: 10
Accepted
time: 0ms
memory: 3876kb
input:
2
output:
10
result:
ok single line: '10'
Test #2:
score: 10
Accepted
time: 0ms
memory: 3840kb
input:
10
output:
122
result:
ok single line: '122'
Test #3:
score: 10
Accepted
time: 0ms
memory: 3940kb
input:
32
output:
130
result:
ok single line: '130'
Test #4:
score: 10
Accepted
time: 0ms
memory: 3760kb
input:
131
output:
8845
result:
ok single line: '8845'
Test #5:
score: 10
Accepted
time: 0ms
memory: 3892kb
input:
2017
output:
10337
result:
ok single line: '10337'
Test #6:
score: 10
Accepted
time: 0ms
memory: 3880kb
input:
13714
output:
3110666
result:
ok single line: '3110666'
Test #7:
score: 10
Accepted
time: 0ms
memory: 3884kb
input:
21313
output:
45467033
result:
ok single line: '45467033'
Test #8:
score: 10
Accepted
time: 1ms
memory: 3836kb
input:
44444
output:
794890
result:
ok single line: '794890'
Test #9:
score: 10
Accepted
time: 1ms
memory: 3880kb
input:
59999
output:
3448141
result:
ok single line: '3448141'
Test #10:
score: 10
Accepted
time: 0ms
memory: 3912kb
input:
1
output:
5
result:
ok single line: '5'