05 2014 档案
01背包 (大数据)
摘要:经典的01背包问题,如果把限制条件改为:重量#include#define INF 10000000using namespace std;int c[105],v[105];int dp[10005]; //dp[i],表示在价值i下的最小重量int main(){ ...
阅读全文
NYOJ 311 完全背包
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=311这道题是完全背包的一个变型,,:求的是把背包装满的最优解.dp方程跟经典的一样:for(i=0; idp[j]) dp[j]=dp[j-c[i]]+w[i]; ...
阅读全文
NYOJ 58 最少步数
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=58经典的迷宫问题,,,,用BFS穷举:#include #include#include#include#define N 9using namespace std;const int INF=...
阅读全文
POJ 2386 Lake Counting
摘要:链接:http://poj.org/problem?id=2386DFS 的入门级题目....依次递归8个方向即可:#include //#includeusing namespace std;char data[105][105];int n,m;void dfs(int x,int y){ ...
阅读全文
第七届河南省ACM A题
摘要:#include #includeusing namespace std;int data[105];int n,m;int ans;void dfs(int i,int sum){ if(sum==m) { ans++; return ; } i...
阅读全文
NYOJ 16 矩形嵌套
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=16最长单调子序列......注意可以不是连续的#include //#include#include#define max( a, b ) ((a>b)?(a):(b))using namesp...
阅读全文
NYOJ 370 波动序列
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=370#include #includeusing namespace std;int main(){ int t; int n; int i; int a; int...
阅读全文
NYOJ 168 房间安排
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=168模拟即可:#include using namespace std;int sign[200];int main(){ int t; int n; int i; in...
阅读全文
NYOJ 113 字符串替换
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=113直接用string类里的fin()和replace()成员函数即可#include #includeusing namespace std;int main(){ string dat...
阅读全文
NYOJ 4 ASCII码排序
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=4水题#include #includeusing namespace std;int main(){ int n; cin>>n; char data[5]; while...
阅读全文
code::blocks基本使用方法
摘要:第一,,,一定要到官网上下,,别的地方下载的都是不自带编译器的,,或者,你的电脑里已经有VS或者别的,设置下就可以,,后面会说怎么设置..这个是官网:http://www.codeblocks.org/ 进去后点download 进入到这个页面 然后,,等3s就开始下载了..~~~~安装就不用说了,...
阅读全文
NYOJ 759 你知道这个规律吗?
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=759找了半天没找到什么规律....直接按大数除法做了 #include #include using namespace std;char num[100005];int main(){ int...
阅读全文
HDU 1321 Reverse Text
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1321水题....记得要吃换行符#include#include int main(){ char data[100]; int t; scanf("%d",&t); getchar(); while(t--...
阅读全文
HDU 1234 开门人和关门人
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1234直接用strcmp()比较时间即可#include #include int main(){ bool judge(char t1[],char t2[]); char id[20]; char t1[...
阅读全文
NYOJ 912 领帽子
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=912全错位排列,按照欧拉给出的递推公式:f(n)=(n-1) {f(n-1)+f(n-2)}#include using namespace std;int main(){ long long ...
阅读全文
NYOJ 495 少年 DXH
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=495直接暴力#include #include char s[100];int main(){ bool isplalindrome(int l); int t; int l; int i,j;...
阅读全文
NYOJ 95 众数问题
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=95理解题意后就很简单了..数组标记法#include using namespace std;int sign[100000];int main(){ int n; int m; cin>>n;...
阅读全文
POJ 3264 Balanced Lineup (RMQ分析)
摘要:链接:http://poj.org/problem?id=3264RMQ (Range Minimum/Maximum Query)问题是指:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,jO(nlogn){ for(int j = 1; j #includeusing namespa...
阅读全文
HDU 1172 猜数字
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1172把1000~9999间的数字遍历一遍,如果只有一个符合条件的话,就输出,否则 not sure#include using namespace std;char data[105][5];int a[1...
阅读全文
HDU 2710 Max Factor
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=2710这道题有点问题,,,是多组数据,要用while(cin),,或者whlie(scanf("")!=EOF)另,要把1当成素数处理.......#include using namespace std;b...
阅读全文
HDU 3346 Lucky Number
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=3346少输出一个感叹号,,wa好几次......#include #include #include using namespace std;int main(){ char buf[100]; int t;...
阅读全文
NYOJ 127 星际之门(一)
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=127//cayley定理#include using namespace std;int main(){ int x,ans,i,m; scanf("%d",&x); while(x--) { ...
阅读全文
BNUOJ 1013 YC大牛的判题任务
摘要:链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=1013水题..用结构体二级排序即可..#include #include using namespace std;typedef struct{ int num; int time;}pro;pr...
阅读全文
BNUOJ 1011 人工智能?
摘要:链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=1011简单题,..字符串查找注意有有小数出现#include #include #include #include using namespace std;string data;int main...
阅读全文
HDU 1035 Robot Motion
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1035简单模拟题...但有几个细节需要注意:1>当输入为0 0 时程序会不会正常结束(如果scanf("%d%d%d",....)是不可以滴)2>走到边缘是不结束的,只要迈出去才算3>注意loop的步数,不要...
阅读全文
HDU 1214 圆桌会议
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1214把每个桌子分成两半,分开考虑。比如,圆桌7个人的话,就分成一个4人的,一个3人的单向序列...分别算出把每个序列反向排序需要的最少交换次数(6,3)。。两个的和即为结果9 ,,再求每个长度为 i 的单向...
阅读全文
NYOJ 86 找球号(一)
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=86用数组标记法爆内存,暴力搜索超时....有一种方法是 快排+二分查找.可以过,但是有点慢.. #include #include #include using namespace std;in...
阅读全文
HDU 2602 Bone Collector
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602简单01背包#include #define MAX( a, b ) ((a>b)?(a):(b)) using namespace std;typedef struct { int value; in...
阅读全文
HDU 1395 2^x mod n = 1
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1395欧拉定理 如果gcd(a,m)==1,a^(euler_phi(n))≡1(mod n)。euler_phi(n)为欧拉函数,其作用是返回与小于n且与n互质的数的个数...令m=euler_phi(n)...
阅读全文
HDU 1896 Stones
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1896学了下优先队列:#include #include #define MAX(a,b) ((a) > (b) ? (a) : (b)) using namespace std;struct node{ i...
阅读全文
priority_queue的用法
摘要:priority_queue调用 STL里面的 make_heap(), pop_heap(), push_heap() 算法实现,也算是堆的另外一种形式。先写一个用 STL 里面堆算法实现的与真正的STL里面的 priority_queue用法相似的priority_queue, 以加深对 pri...
阅读全文
NYOJ 28 大数阶乘
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=28大数问题。模拟手工运算,用一个变量储存进位:被乘数逐位乘以乘数。#include #include #include int ans[20000];char tem[5];int t; ...
阅读全文
ZJU 1272 Numerically Speaking
摘要:大数问题......根据先余为低位,后余为高位的基本思想,进行26->10进制的互相转换。注意如果输入为的10进制数为26的整数时,要先减一再求余,最后结果在加a..因为目标进制没有表示0的数Presentation Error 了好几次。。要看到这句话“and the corresponding ...
阅读全文
NYOJ 625 笨蛋的难题(二)
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=625刚开始以为是博弈方面的问题,浪费了不少时间。这道题的解法有点像动态规划,同时也有点贪心的意思总体思想是倒推,分解成多个子问题,从后往前算...first记录从当前位置向后先取的最大值,las...
阅读全文
NYOJ 102 次方求模
摘要:链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=102用二分求幂:注意要用长整形 #include int main(){ long long power(int a,int b,long long c); int n; int a,b,c; ...
阅读全文
ZJU Least Common Multiple
摘要:#include#includeint *data;int main(){ void lcm(int n); int m; int n; int i; scanf("%d",&m); while(m--) { scanf("%d",&n); data=(int *)malloc(sizeo...
阅读全文
ZJUOJ 1073 Round and Round We Go
摘要:链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=73高精度乘法。一次乘以2~len,再判断是否是原字符串的一个cut-string 有一个函数叫strstr()..用上能精简很多代码。。#include#includecha...
阅读全文
|
|
|
26 |
27 |
28 |
29 |
30 |
31 |
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
11
|
12
|
13
|
14
|
15
|
16
|
17
|
18
|
19
|
20
|
21
|
22
|
23
|
24
|
25
|
26
|
27
|
28
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
|
|
|