/ Randle /

记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 2ms 320.0 KiB
#2 Accepted 2ms 308.0 KiB
#3 Accepted 1ms 320.0 KiB
#4 Accepted 1ms 312.0 KiB
#5 Accepted 1ms 316.0 KiB
#6 Accepted 2ms 304.0 KiB
#7 Accepted 1ms 320.0 KiB
#8 Accepted 1ms 304.0 KiB
#9 Accepted 1ms 316.0 KiB
#10 Accepted 1ms 316.0 KiB

代码

#include<bits/stdc++.h>
using namespace std;
long long n, m;
long long fib[100];
long long calc(long long a, long long b) {
if (a == b) return a;
if (a < b) swap(a, b);
return calc(b, a - b);
}
long long check(long long x, long long y) {
fib[0] = 1;
fib[1] = 1;
for(int i = 2; i < 75; i++) fib[i] = fib[i - 1] + fib[i - 2];
long long res = 0;
for(int i = 1; i < 70; i++) {
if (x * fib[i] % fib[i + 1] == 0) {
long long z = x * fib[i] / fib[i + 1];
res = max(res, (x - calc(x, z)) * y);
}
}
return res;
}
int main()
{
scanf("%lld%lld", &n, &m);
printf("%lld\n", max(check(n, m), check(m, n)));
}

信息

递交者
类型
递交
题目
切蛋糕 T1
题目数据
下载
语言
C++
递交时间
2017-10-05 18:31:56
评测时间
2017-10-05 18:31:56
评测机
分数
100
总耗时
19ms
峰值内存
320.0 KiB