QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#318815#4640. 反正切函数的应用plmlees100 ✓1ms3940kbC++14571b2024-01-31 21:14:092024-01-31 21:14:09

Judging History

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

  • [2024-01-31 21:14:09]
  • 评测
  • 测评结果:100
  • 用时:1ms
  • 内存:3940kb
  • [2024-01-31 21:14:09]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'