自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 资源 (1)
  • 收藏
  • 关注

原创 幂取模

#include #include #include using namespace std;int pow_mod(int a, int n, int m) { //时间复杂度:O(logn) if(n == 1) { return a%m; } int x = pow_mod(a, n/2, m); long long ans = (long long)x *

2013-02-24 15:11:26 909

原创 poj1284Primitive Roots(欧拉函数)

#include #include #include using namespace std;//Accepted 164K 0MSint work(int n) { int rea = n; for(int i = 2; i*i<=n; i++) { if(n%i == 0) { rea = rea - rea/i;

2013-02-23 17:20:32 955

原创 POJ2407Relatives(欧拉函数入门题目)

#include #include #include using namespace std;//Accepted 164K 0MS C++ 472Bint work(int n) { int rea = n; for(int i = 2; i*i<=n; i++) { if(n%i == 0) { rea = rea - rea/

2013-02-23 17:05:17 1318

原创 POJUbiquitous Religions(非常棒的并查集入门题目)

#include #include using namespace std;int f[50010];int sum = 0;//Accepted 360K 313MSint find1(int x) { if(f[x] != x) { f[x] = find1(f[x]); } return f[x];}void merge1(int a

2013-02-22 11:58:00 1331 2

原创 POJ1833(字典序的排序算法)

#include #include #include #include using namespace std;//Accepted 168K 454MS C++bool gen_perm(int *a, int n) { if(n == 1) { return false;} int i, j, k, t; for(j = n-2; j >= 0; j--)

2013-02-21 17:44:28 1348

原创 POJ1833 排列

#include #include #include #include //Accepted 168K 454MS C++using namespace std;int num[1024+10];int main(){ int T, n; int p; scanf("%d", &T); while(T--) { scanf("%d%d

2013-02-21 16:03:44 939

原创 STL_qsort(对int,char,vector,结构体排序举例)

#include #include #include #include #include using namespace std;int cmp_int(const void *a, const void *b) { return *(int *)a - *(int *)b;}bool cmp_stl(int a, int b) { return a > b;

2013-02-20 19:46:17 3082 2

原创 sort和qsort对字符数组排序

#include #include #include #include using namespace std;//升序比较:第一个元素比第二个元素大返回正数(这是元素需要交换的条件)int compare_rise(const void *a,const void *b) { return *(char*)a - *(char*)b;}//降序比较:第二个元素比第一个

2013-02-20 18:54:54 2417

原创 STL_stack_queue(非常基础重要)

#include #include #include #include #include using namespace std;void queue_list() { queue > q1; int i; for(i = 0; i < 10; ++i) { q1.push(i); } while(!q1.empty()) {

2013-02-20 13:02:28 1036

原创 STL_vector常见用法举例

#include #include #include using namespace std;void test_init() { cout << "test_init: " << endl; vector content(20); cout << content.size() << endl; vector v(10, 90); cout <

2013-02-19 17:13:03 1170

原创 POJ1664(放苹果,感觉比较有意思)

#include#include #include using namespace std;int counter(int x,int y) { if(y==1 || x==0) { return 1; } if(x<y) return counter(x, x); return counter(x,y-1) + counter(x-y,y);}int

2013-02-18 23:32:12 893

原创 hdu1719(Friend)

#include #include #include using namespace std;int main(){ int n; while(scanf("%d", &n) != EOF) { if(n == 0) { printf("NO!\n"); continue; } ///n = 0 let me WA! int tmp

2013-02-18 21:43:39 889 1

原创 感悟

离开学越来越近了,在家 不能拿拿这本,看看那本,泛读几本书,不如踏踏实实把《算法入门经典-训练指南》和《编程实验》的部分章节认真研读并上机实验!

2013-02-17 23:39:19 794 1

原创 易炸物LA3644(并查集)

#include #include #include using namespace std;const int maxn = 100000 + 10;int f[maxn];int find(int x) { return f[x] != x ? f[x] = find(f[x]) : x;}int main() { int x, y; while(scanf("%d"

2013-02-17 23:20:57 1036

原创 内存相关(C/C++)基础知识

#include #include #include #include using namespace std;struct s{ int x:3; int y:4; int z:5; double a; }; struct a { int x:4; int y:5; int z:6; int c;

2013-02-17 22:46:03 1071 1

转载 RMQ问题3.2.1

#include #include #include #include #include #define MAXN 50010#define Max(x,y) (x>y?x:y)#define Min(x,y) (x>y?y:x)using namespace std; ///8540K 3422MS G++int maxsum[MAXN][20],minsum[MAXN][

2013-02-17 17:17:54 670

原创 乘积最大

【题目描述】今年是国际数学联盟确定的“2000——世界数学年”,又恰逢我国著名数学家华罗庚先 生诞辰90周年。在华罗庚先生的家乡江苏金坛,组织了一场别开生面的数学智力竞赛的活 动,你的一个好朋友XZ也有幸得以参加。活动中,主持人给所有参加活动的选手出了这样 一道题目:设有一个长度N的数字串,要求选手使用K个乘号将它分成K+1个部分,找出一种分法,使得这K+1个部分的乘积能够为最大。同时,为

2013-02-06 21:00:47 1071 1

原创 添加括号使表达式的值最大(表达式仅含加号和乘号)

动态规划问题:添加括号使表达式的值最大给定一个表达式(只有加法和乘法两种运算),要求通过添加括号使得表达式的值最大譬如说100×100+100×100×100+100×100的最大值是(100×(100+100))×((100×(100+100))×100)=40000000000设原计算式为: n1 op1 n2 op2 n3 op3 ... n[m-1] op[m-1] n[m].

2013-02-06 19:31:32 5877

转载 有12个乒乓球,其中一个是坏的,请你用天枰称3次将坏球分辨出来。你会用什么方法呢?

出处:http://blog.sina.com.cn/s/blog_45988eca0100jgxe.html我是这么干的:先将12个球分别编上号1、2、3-12。 第一次:将1-4号放在天枰左边,5-8号放在天枰右边,称。结果是不平衡,可以推断剩下的9-12号球完好无损。而前面这已经称量的8个球有一个是坏球,只有一种情况,就是现在已经知道这个球是轻或是重。即1-4不轻就重,不可能

2013-02-05 13:07:38 1312

原创 hdu 称乒乓球

Problem Description有N只乒乓球,其中有且仅有1只质量有问题,比正常的球要轻一些。给你一驾没有砝码的天平,你最少要多少次才能保证找到有问题的乒乓球?Input输入包含多组数据每组数据输入一个整数N(N<=1000)Output对于每组数据,输出最少的称量次数Sample Input26Sample Output12#include #inclu

2013-02-05 12:31:08 888

原创 C语言学习

#include #include using namespace std;int strleng( char const str[]) { ///only read int i = 0; while(str[i] != '\0') { i++; } return i;}int main(){ char str[100];

2013-02-04 22:59:37 641

转载 C/C++内存分析

//http://blog.csdn.net/morewindows/article/details/6851681#include #include int g_i = 100;int g_j = 200;int g_k, g_h;int main(){ const int MAXN = 100; int *p = (int*)malloc(MAXN * sizeo

2013-02-03 20:25:58 655 1

原创 求数组的子数组之和的最大值(编程之美P183)

#include //data: 2013.2.3#include #include const int N = 1000;using namespace std;int get_sum(int *a, int n ) { int start[N], all[N]; int i; start[n-1] = a[n-1]; all[n-1] =

2013-02-03 16:19:45 858

原创 hdu 1087

/******************31ms 256k2013.2.2http://acm.hdu.edu.cn/showproblem.php?pid=1087****************/#include #include #include int digit[1005];int tmp[1005];int biggest(int n){ int res

2013-02-02 12:58:52 678

原创 思考指针!

#include #include #include using namespace std;void fun(char *w, int n) { char *s1 = w; char t; char *s2 = w + n - 1; printf("%c ", *s2); while( s1 < s2 ) { t = *s1+

2013-02-01 19:42:51 746

原创 hdu 2602

/*****************2013.2.1hdu 2602Achiberxtime:46ms mem: 4244khttp://acm.hdu.edu.cn/showproblem.php?pid=2602*****************/#include #include #include const int maxn = 1010;using namespac

2013-02-01 10:24:54 719

原创 OJ

我们学各种编程语言的同学一定要来这些地方做些题看下自己的水平南阳理工学院 http://acm.nyist.net/JudgeOnline/浙江大学 http://acm.zju.edu.cn 北京大学 http://acm.pku.edu.cn/JudgeOnline或者http://poj.org/天津大学 http://acm.tju.edu.cn厦门大学 http://acm.x

2013-02-01 09:35:39 1108

程序员面试笔试宝典

面试笔试必看,讲解数据结构和算法,怎么写简历,面试技巧等等

2014-02-21

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除