sgu287:Amusing Qc Machine(DP)

题目大意: 与,,求出在最坏情况下结束游戏所需的最少轮数。

分析: 硬蛋那道题,和这道题有异曲同工之妙。 表示轮游戏能确定的最大区间。 ,再把数组循环一下就好了。

AC code:

LL;typedef double DB;LD;;const int MAXC = 1e6+9;LL q;int c;LL f[MAXC];LL ans;void open_init(){#ifndef ONLINE_JUDGEfreopen(“input.txt”, “r”, stdin);freopen(“output.txt”, “w”, stdout);#endifios::sync_with_stdio(0);}void close_file(){#ifndef ONLINE_JUDGEfclose(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;}

一个今天胜过两个明天

sgu287:Amusing Qc Machine(DP)

相关文章:

你感兴趣的文章:

标签云: