标签:dp
题目大意:
分析:
AC code:
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define clr(x, y) memset(x, y, sizeof x)
#define mod(a, b) ((a)<(b)?(a):((a)-(b)))
typedef long long LL;
typedef double DB;
typedef long double LD;
using namespace std;
const int MAXC = 1e6+9;
LL q;
int c;
LL f[MAXC];
LL ans;
void open_init()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios::sync_with_stdio(0);
}
void close_file()
{
#ifndef ONLINE_JUDGE
fclose(stdin);
fclose(stdout);
#endif
}
int main()
{
open_init();
cin >> q >> c;
int cnt = 0;
while(f[mod(cnt, c+1)] < q)
f[mod(cnt, c+1)] = f[mod(cnt, c+1)]+f[mod(cnt+c, c+1)]+1,
cnt = mod(cnt+1, c+1), ans++;
cout << ans << endl;
close_file();
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:dp
原文地址:http://blog.csdn.net/qq_20118433/article/details/46942623