摘要:
题意:给定M和多组Ai、Bi,求公式(A1B1+A2B2+ ... +AHBH)mod M。思路:快速幂O(logn)模板~题目链接:http://poj.org/problem?id=1995View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <algorithm> 5 #include <string> 6 #include <iostream> 7 using namespace std; 8 9 long 阅读全文
摘要:
题意:给3个字符串,问第三个串能不能由前两个构成,在不改变相互顺序的情况下!思路:记忆化搜索,开个hash数组保存,否则超时~题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1501View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <string> 5 #include <algorithm> 6 #include <iostream> 7 using namespa 阅读全文
摘要:
想想,学习算法已经有一年多了,这么长时间以来,一直为了自己的梦想执着的坚持着,在参加比赛后才发现,自己是那么的菜,望着蓝天、有些迷茫。 想想自己学了这么长时间的算法,学的有些杂乱,导致了学习效果不甚理想,为此,决定开始停止HDU的训练,进军POJ,系统的学习下算法,一步一个脚印,踏实的学好每一个算法! 一个人坐在实验室中,开始刷题~ 阅读全文
摘要:
题意:给你四个数a,b,c,d,让你求满足等式a*x1^2+b*x2^2+c*x3^2+d*x4^2=0;的x的个数。思路:经典Hash,开两个数组分别保存正数和负数,时间复杂度降到n^2。题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1496View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <algorithm> 5 #include <string> 6 #include 阅读全文