BZOJ

来源:互联网 发布:炉石大数据各数据意义 编辑:程序博客网 时间:2024/06/08 04:35

这里写图片描述
这里写图片描述

#include <algorithm>#include <iostream>#include <cstring>#include <cstdlib>#include <cstdio>#include <cmath>#include <set>using namespace std;typedef long long int LL;const LL INF = 1e18;const int N = 1000005;int n, r, p;LL dp[N];LL dfs(int n){    if (dp[n])        return dp[n];    if (n <= 1)        return 0;    dp[n] = (LL)(n - 1) * p + r;    for (int i = 2; i < n;) {        dp[n] = min((LL)(i - 1) * p + dfs(ceil(n * 1.0 / i)) + r, dp[n]);        i = ceil(n * 1.0 / (ceil(n * 1.0 / i) - 1));    }    return dp[n];}int main(){    //freopen("test.txt", "r", stdin);    //freopen("out.txt", "w", stdout);    scanf("%d%d%d", &n, &r, &p);    printf("%I64d\n", dfs(n));    return 0;}
原创粉丝点击