poj-2591
来源:互联网 发布:ubuntu编译配置lnmp 编辑:程序博客网 时间:2024/05/18 16:14
//39360K 172MS C++#include <cstdio>#include <cstring>const int MAX = 10000005;long num[MAX];long MIN(long a, long b) { return a < b ? a: b;}void init() { num[0] = 1; int p1 = 0; int p2 = 0; for (int i = 1; i < MAX; i++) { num[i] = MIN(2*num[p1] + 1, 3*num[p2] + 1); if (num[i] == 2*num[p1] + 1) p1++; if (num[i] == 3*num[p2] + 1) p2++; }}int main() { int ordinal; init(); while(scanf("%d", &ordinal) != EOF) { printf("%ld\n", num[ordinal - 1]); }}
poj-2545的简单变形,注意数组要开成long 的,long long的MLE了.
0 0
- poj 2591
- poj-2591
- POJ-2591
- POJ 2591 Set Definition
- POJ 2591 Set Definition
- poj 2591 Set Definition
- poj 2591,1338 DP
- POJ 2591 解题报告
- poj 2591 Set Definition
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- 最长公共子序列(Longest Common Subsequence, LCS)
- Redis Sentinel:集群Failover解决方案
- 美国免投诉空间、外贸仿牌网站建设
- android ViewHolder优化
- 中序表达式 to 后序表达式
- poj-2591
- 影响CSS渲染速度的写法与建议
- LeetCode - Partition List
- [转载]ANDROID内存优化(大汇总——上)
- Mac OS X终端命令开启功能
- Qt编译过程中出现的问题
- js,jq清除360浏览器自动保存保单信息
- TCP
- 图的矩阵表示