摘要: 该题题意很简单,题目中定义了丑数的概念,即这个数只有2,3,5这几个因子,现在要我们输出前1500个丑数的任意一个.前面没想到好的方法,直接想着打表了,前面700个能够在线跑出来,后面的就打了个表.#include <cstdio>#include <cstring>#include <cstdlib>#include <iostream>#include <algorithm>using namespace std;bool is(int x) { while (x % 2 == 0) x /= 2; while (x % 3 == 阅读全文
posted @ 2013-01-10 21:50 沐阳 阅读(393) 评论(0) 推荐(0)
摘要: #include <cstring>#include <cstdio>#include <cstdlib>#include <algorithm>using namespace std;/*该题给定一个N,那么在有1.2.3...N个数字的情况下,这些数字高低交替进行排列把所有符合情况的进行一个字典序排列,问第C个排列是一个怎样的排列up[i][j]代表长度为i,第一位为j且后面需跟着一个上升数字的方案总数dn[i][j]代表长度为i,第一位为j且后面需跟着一个下降数字的方案总数根据我们所定义的状态,我们能够得到一个状态的转移关系(用来状态转移来 阅读全文
posted @ 2013-01-10 14:27 沐阳 阅读(365) 评论(0) 推荐(0)