随笔分类 - ACM
摘要:4497http://fudq.blog.163.com/blog/static/19135023820137294929320/http://www.cnblogs.com/liuxueyang/archive/2013/08/26/3281680.htmlhttp://tech.ddvip.com/2013-11/1383560842205344.html
        阅读全文
                
摘要:1 //http://acm.hdu.edu.cn/showproblem.php?pid=1047 2//这题要说的,我觉得就是要考虑进位的问题,而且不是进一位两位,可能是很多位,//不过好像不考虑也能过,估计是测试数据太弱了。//还有就是题目讲了半天不知道再扯什么东西,,,给的Input感觉有问题,,,//水过就好。。。。 3 #include 4 #include 5 using namespace std; 6 int main() 7 { 8 int n,i,a,l; 9 char s[100]; 10 while(cin>>n)11 ...
        阅读全文
                
摘要://http://acm.hdu.edu.cn/showproblem.php?pid=1098/*题目说x任意,于是取x=1,公式变为f(x)=5+13+k*a然后从小到大枚举a,满足f(x)%65==0即输出,枚举a为1到64,因为a>=65时可简化为 65+i,65可以约去有一个函数: f(x)=5*x^13+13*x^5+k*a*x给定一个非负的 k 值 求最小的非负的 a 值 使得对任意的整数x都能使 f(x) 被 65 整除。每输入一个k 值 , 对应输出一个 a值 , 若不存在a值 则输出 no 数学归纳法证明:1.假设当x=n时,f(n)=...........
        阅读全文
                
摘要://http://acm.hdu.edu.cn/showproblem.php?pid=2098//标准的筛选法 #includeusing namespace std;bool prime[10000+5]; //题目中给出了数值不会超过10000,这样刚好能够用筛选法 void Init() //直接初始化素数表就好了。 { for(int i = 2; i <= 10000; ++i) //初始条件为都是素数 { prime[i] = true; } for(int i =2;i <= 10000; ++i) ...
        阅读全文
                
摘要://超级水题,热身的,没必要解释//http://acm.hdu.edu.cn/showproblem.php?pid=2161#includeusing namespace std;bool IsPrime(int n){ int i = 0; if(n0 ) { count++; if(IsPrime(N)) printf("%d: yes\n",count); else printf("%d: no\n",count); } return 0;}
        阅读全文
                
摘要://http://acm.hdu.edu.cn/showproblem.php?pid=1395//同样,快速幂取余不用解释,注意点输出格式就行了//注意全部使用位运算#includeusing namespace std;__int64 Montgomery(int a, int b, int r){ __int64 ans=1, buff=a; while(b) { if(b&1) ans = ans*buff%r; buff = buff*buff%r; b>>=1; } return ans;}int ma...
        阅读全文
                
摘要:人见人爱A^BTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 17481Accepted Submission(s): 12376Problem Description求A^B的最后三位数表示的整数。说明:A^B的含义是“A的B次方”Input输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1 3 4 using namespace std; 5 6 __int64 qpow(int a,int b,int r) 7 {...
        阅读全文
                
摘要:本文地址:http://www.cnblogs.com/Lee-geeker/p/3372084.html转载请注明。1.最大公约数和最小公倍数。//模版int gcd(int a, int b){ if(ausing namespace std;int gcd(int a, int b){ if(a>=1; } return ans;}可参考题目:HDU1395 http://acm.hdu.edu.cn/showproblem.php?pid=1395#includeusing namespace std;unsigned Montgomery(unsigned ...
        阅读全文
                
摘要:AuthorIgnatius.L题目大意:1.第一行输入一个整数T代表接下来有T组测试数据。2.接下来的T行,每行输入一个整数(1#include int main(void){ int n, i, ncase; long long x; scanf("%d", &ncase); for(i = 0; i :lg(a.~)=lg(num)-n; 又n为num的总位数减1,n=(int)lg(num); ->:a.~=pow(10,1g(num)-(int)(lg(num)));*/#include #include #include #include usin
        阅读全文
                
摘要://题目地址//http://acm.hdu.edu.cn/showproblem.php?pid=1071 1 #include 2 #include 3 using namespace std; 4 5 int main() 6 { 7 int T; 8 double x1,x2,x3,y1,y2,y3,a,b,c,k,t,x,s1,s2; 9 cin>>T;10 while(T--)11 {12 cin>>x1>>y1>>x2>>y2>>x3>>y3;13 a=(y2-y1)/((x1-x2)*(x1-x
        阅读全文
                
摘要:1 //http://acm.hdu.edu.cn/showproblem.php?pid=2037 1 //贪心问题:选择不相交的区间问题 2 3 4 #include 5 #include 6 using namespace std; 7 8 typedef struct _NODE_ //结构体 9 {10 int Ti_s;11 int Ti_e;12 13 }Node;14 15 Node TV[101];16 17 int cmp(Node x,Node y) //排序规则 18 {19 return x.Ti_e = t...
        阅读全文
                
摘要://原题目地址//http://acm.hdu.edu.cn/showproblem.php?pid=1009//经典贪心题目/*其实贪心都是还是其次的,这里用结构体来装Room的信息,然后用sort来排序.*/#include#includeusing namespace std;typedef struct _NODE_{ double J; //JavaBean double F; //cat food double V; //性价比 }Node;Node Room[1001]; //定义出来1001个结构体,...
        阅读全文
                
摘要:1 sort函数的用法 2 3 做ACM题的时候,排序是一种经常要用到的操作。如果每次都自己写个冒泡之类的O(n^2)排序,不但程序容易超时,而且浪费宝贵的比赛时间,还很有可能写错。STL里面有个sort函数,可以直接对数组排序,复杂度为n*log2(n)。使用这个函数,需要包含头文件。 4 这个函数可以传两个参数或三个参数。第一个参数是要排序的区间首地址,第二个参数是区间尾地址的下一地址。也就是说,排序的区间是[a,b)。简单来说,有一个数组int a[100],要对从a[0]到a[99]的元素进行排序,只要写sort(a,a+100)就行了,默认的排序方式是升序。 5...
        阅读全文
                
摘要:交了4次才过,以为很简单,结果大意了。。注意两个问题:一个是考虑可能的溢出情况,这个以前就遇到过,所以这里没有忘记 1 int lcm(int a, int b) 2 { 3 return a/gcd(a,b)*b; 4 } 5 6 7 //避免写成这样 8 int lcm(int a, int b) 9 {10 return a*b/gcd(a,b); //可能会溢出11 }第二个是考虑特殊数据1 //如果数据是这个样子的2 23 1 34 1 45 6 这样只有一个数据7 那么直接输入a[0],即为最大公约数了考虑以上就能轻松AC 1 #include 2 3 usi...
        阅读全文
                
摘要:Twilightgod CUST http://blog.csdn.net/twilightgodAekdycoin FZU http://hi.baidu.com/aekdycoinForeverlin HNU http://hi.baidu.com/forverlin1204/blogMatrix67 PKU http://www.matrix67.com/blog/watashi ZJU http://watashi.ws/blog/tag/zoj/Sha崽 HDU http://www.notonlysuccess.comChenyajun...
        阅读全文
                
摘要:1.Oline JudgeCII题库https://icpcarchive.ecs.baylor.edu/杭电 http://acm.hdu.edu.cn/杭电题目分类:http://acm.hdu.edu.cn/typeclass.phpNOYJ http://acm.nyist.net/JudgeOnline/problemset.phpPOJ http://poj.org/九度 http://ac.jobdu.com/ZOJ http://acm.zju.edu.cn/ZOJ News http://acm.zju.edu.cn/onlinejudge/ZOJ题目分类 http://..
        阅读全文
                
摘要:题目:62进制(非大数除法实现) '0'-'9'-----0-9 A-Z-------10-35 a-z--------36-62具体说明可以参考此博客http://www.cppblog.com/kuangbin/archive/2011/08/25/154299.html?opt=admin在此简短说一下: 例如 10进制的18 转换为2进制 被除数 除数 商 余数 1 8 / 2---------09 0 ---------- 1轮结束9/2 -------- 4 1 --------- 2轮结束 4 / 2-------- 2 0 ---------3轮
        阅读全文
                
摘要:Eddy's digital RootsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3561 Accepted Submission(s): 2013Problem DescriptionThe digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a sin...
        阅读全文
                
摘要:快速排序(Quicksort)是对冒泡排序的一种改进。由C. A. R. Hoare在1962年提出。它的基本思想是:通过一趟排序将要排序的数据分割成独立的两部分,其中一部分的所有数据都比另外一部分的所有数据都要小,然后再按此方法对这两部分数据分别进行快速排序,整个排序过程可以递归进行,以此达到整个数据变成有序序列。快速排序使用分治法(Divide and conquer)策略来把一个串行(list)分为两个子串行(sub-lists)。步骤为:从数列中挑出一个元素,称为 "基准"(pivot),(定基准,有随机版本)重新排序数列,所有元素比基准值小的摆放在基准前面,所有元
        阅读全文
                
摘要:时间复杂度(渐近时间复杂度的严格定义,NP问题,时间复杂度的分析方法,主定理)排序算法(平方排序算法的应用,Shell排序,快速排序,归并排序,时间复杂度下界,三种线性时间排序,外部排序)数论(整除,集合论,关系,素数,进位制,辗转相除,扩展的辗转相除,同余运算,解线性同余方程,中国剩余定理)指针(链表,搜索判重,邻接表,开散列,二叉树的表示,多叉树的表示)按位运算(and,or,xor,shl,shr,一些应用)图论(图论模型的建立,平面图,欧拉公式与五色定理,求强连通分量,求割点和桥,欧拉回路,AOV问题,AOE问题,最小生成树的三种算法,最短路的三种算法,标号法,差分约束系统,验证二分图
        阅读全文
                
                    
                
浙公网安备 33010602011771号