Fork me on GitHub

  2013年1月13日
摘要: #include "stdio.h"#include "stdlib.h"#include "algorithm"int main(){ int i,j,temp,m,n,flag; long long aim; long long **a; a=(long long**)malloc(sizeof(long long*)*1000); for(i=0;i<1000;i++) {a[i]=(long long*)malloc(sizeof(long long)*1000);} while(scanf("%d %d&qu 阅读全文
posted @ 2013-01-13 21:12 huashiyiqike 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 做ACM题的时候,排序是一种经常要用到的操作。如果每次都自己写个冒泡之类的O(n^2)排序,不但程序容易超时,而且浪费宝贵的比赛时间,还很有可能写错。STL里面有个sort函数,可以直接对数组排序,复杂度为n*log2(n)。使用这个函数,需要包含头文件。 这个函数可以传两个参数或三个参数。第一个参数是要排序的区间首地址,第二个参数是区间尾地址的下一地址。也就是说,排序的区间是[a,b)。简单来说,有一个数组int a[100],要对从a[0]到a[99]的元素进行排序,只要写sort(a,a+100)就行了,默认的排序方式是升序。 拿我出的“AC的策略”这题来说,需要对数组t的第... 阅读全文
posted @ 2013-01-13 15:54 huashiyiqike 阅读(579) 评论(0) 推荐(0) 编辑
摘要: 大数:求下一个质数#include "stdio.h"#include "math.h"#define maxsize 1000000int main(){ __int64 i,j,temp,count,sq,n; bool flag=true; scanf("%I64d",... 阅读全文
posted @ 2013-01-13 15:23 huashiyiqike 阅读(478) 评论(0) 推荐(0) 编辑