随笔分类 - ACM—各种模板
摘要:题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2718题意:优先直走,右 左 后。。。。思路:我定义的朝向 已经 d[]的先后次序。。。。。3214 1 #include 2 #include 3 using namespace std; 4 5 int dx[5]={0,1,-1,0,0}; 6 int dy[5]={0,0,0,1,-1}; 7 struct node 8 { 9 int x,y,tow,step; 10 }pos,before; 11 in...
阅读全文
摘要:题目:http://poj.org/problem?id=1039题意:有一宽度为1的折线管道,上面顶点为(xi,yi),所对应的下面顶点为(xi,yi-1),假设管道都是不透明的,不反射的,光线从左边入口处的(x1,y1),(x1,y1-1)之间射入,向四面八方传播,求解光线最远能传播到哪里(取x...
阅读全文
摘要:题目:http://codeforces.com/problemset/problem/135/B题意:给8个点 判断能否用 4个点构成正方形,另外4个点构成 矩形。输出 第一行是正方形 ,第二行是矩形。我的思路:用了4个for循环 枚举四个点, 用向量判断,四个点构成 六条边,如果这六条边里,有四...
阅读全文
摘要:题目:http://poj.org/problem?id=2635高精度求模 同余模定理。题意:给定一个大数K,K是两个大素数的乘积的值。再给定一个int内的数L问这两个大素数中最小的一个是否小于L,如果小于则输出这个素数。思路:Char格式读入K。把K转成千进制Kt,同时变为int型。把数字往大进...
阅读全文
摘要:题目:http://poj.org/problem?id=1850题意:按给定的规则给字母编号。一个很简单的题目,但是却做了好久。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 1 #include 2 #include 3 #include 4 using namespace std; 5 int c[30][30]; 6 void init()//用杨辉三角的方法求组合数,C(n,m) 7 { 8 int i,j; 9 for(i=0; i>s;21 22 k=strlen(s);23 for(i=0; ...
阅读全文
摘要:题目:http://poj.org/problem?id=1276题意:费用和价值相同的多重背包。以前看背包的时候做过,今天又做了一遍。二进制优化代码 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int _max(int ...
阅读全文
摘要:题目:http://poj.org/problem?id=3126题意:给定两个四位数,求从前一个数变到后一个数最少需要几步,改变的原则是每次只能改变某一位上的一个数,而且每次改变得到的必须是一个素数; 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include11 #include12 using namespace std;13 14 int p[10010],vis[10010];15 int a,b,t;16 struct n.
阅读全文
摘要:题目:http://poj.org/problem?id=2299这个题目实际就是求逆序数,注意 long long上白书上的模板 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include ...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=1500&cid=1147View Code 1 #include 2 #include 3 #include 4 5 struct node 6 { 7 int flag; 8 ...
阅读全文