上一页 1 ··· 42 43 44 45 46 47 48 49 50 ··· 182 下一页
摘要: 简单题,打表View Code #include <iostream>using namespace std;int ans[] = {0, 2, 7, 5, 30, 169, 441, 1872, 7632, 1740, 93313, 459901, 1358657, 2504881}, n;int main(){ while (cin >> n && n != 0) cout << ans[n] << endl; return 0;} 阅读全文
posted @ 2012-12-10 12:30 undefined2024 阅读(154) 评论(0) 推荐(0)
摘要: 题意:给出一些木棒,已知这些木棒是由原来的一些等长的木棒切割而成,问原木棒最小可能长度是多少。分析:dfs。从小到大枚举原木棒长度,然后对于每次枚举进行深搜。深搜过程就是用输入的小木棒来填充原来的一根根木棒的过程。如果我们现将一根小木棒是放在原木棒中的第一根小木棒,那么如果还不能匹配成功,则说明该小木棒无法匹配,故该原木棒长度不行。如果一根小木棒是填充一根原木棒时用的最后一根小木棒,且后面填充其他原木棒是出现了不匹配的现象回溯到这一跟小木棒的时候,不需要再尝试将这跟小木棒换掉然后用一些更小的小木棒来填充这个小木棒的长度,因为那些更小的小木棒具有更好的灵活性,他们都不能完成后面的任务,更不用说这 阅读全文
posted @ 2012-12-09 18:58 undefined2024 阅读(167) 评论(0) 推荐(0)
摘要: dfsView Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;#define maxn 300int n;int m, tot;int stamp[maxn];int ans[5], ansnum;int sel[5];bool tie, none;bool vis[maxn];void input(){ n = 1; if (scanf(" 阅读全文
posted @ 2012-12-07 20:28 undefined2024 阅读(417) 评论(0) 推荐(0)
摘要: 简单模拟View Code //poj1008#include <iostream>#include <string>using namespace std;int n, days;void init(){ int day, year, month; string mon; cin >> day; getchar(); getchar(); cin >> mon; cin >> year; if (mon == "pop")month = 1; if (mon == "no")month = 2 阅读全文
posted @ 2012-12-04 16:10 undefined2024 阅读(635) 评论(0) 推荐(0)
摘要: 简单排序View Code //poj1007#include <iostream>#include <algorithm>#include <string>using namespace std;const int maxn = 101;struct item{ string sequence; int unsort;}dna[maxn];int n, m;bool operator<(item a, item b){ return a.unsort < b.unsort;}int calculate(string s... 阅读全文
posted @ 2012-12-03 14:39 undefined2024 阅读(174) 评论(0) 推荐(0)
上一页 1 ··· 42 43 44 45 46 47 48 49 50 ··· 182 下一页