自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

bo-jwolf的专栏

不求最强,但求无悔!!!

  • 博客(65)
  • 资源 (1)
  • 收藏
  • 关注

原创 C++的输出精度控制

使用这些格式需要声明包含long flags( ) const 返回当前的格式标志。long flays(long newflag) 设置格式标志为newflag,返回旧的格式标志。long setf(long bits) 设置指定的格式标志位,返回旧的格式标志。long setf(long bits,long field)将field指定的格式标志位置为bits,返回旧的格式

2013-07-18 11:26:00 1981 4

原创 中国剩余定理

中国剩余定理介绍     在《孙子算经》中有这样一个问题:“今有物不知其数,三三数之剩二(除以3余2),五五数之剩三(除以5余3),七七数之剩二(除以7余2),问物几何?”这个问题称为“孙子问题”,该问题的一般解法国际上称为“中国剩余定理”。具体解法分三步:找出三个数:从3和5的公倍数中找出被7除余1的最小数15,从3和7的公倍数中找出被5除余1 的最小数21,最后从5和7的公倍数

2013-07-17 15:07:03 3148 2

原创 灌水问题

倒水问题的经典形式是这样的:  “假设有一个池塘,里面有无穷多的水。现有2个空水壶,容积分别为5升和6升。问题是如何只用这2个水壶从池塘里取得3升的水。”  当然题外是有一些合理的限制的,比如从池塘里灌水的时候,不管壶里是不是已经有水了,壶一定要灌满,不能和另一个壶里的水位比照一下“毛估估”(我们可以假设壶是不透明的,而且形状也不同);同样的,如果要把水从壶里倒进池塘里,一定要都倒

2013-07-17 10:57:50 1709

原创 poj2115一次模余定理

http://poj.org/problem?id=2115#include#include#include#include#include#include#includeusing namespace std;typedef __int64 INT ;INT ex_gcd( INT a , INT b , INT &x ,INT &y ){ if ( b == 0

2013-07-28 15:31:19 826

原创 poj2891一次线性模余定理

http://poj.org/problem?id=2891#include#include#include#include#include#include#includeusing namespace std;typedef __int64 INT ;INT ex_gcd( INT a , INT b , INT &x ,INT &y ){ if ( b == 0 )

2013-07-28 14:57:47 966

原创 hdu2035同余问题

http://acm.hdu.edu.cn/showproblem.php?pid=2035#include#include#include#include#include#include#includeusing namespace std;int main(){ int a , b ; int i , j , sum ; while( scanf( "%d%d"

2013-07-27 22:38:24 856

原创 hdu1021-同余问题

http://acm.hdu.edu.cn/showproblem.php?pid=1021#include#include#include#include#include#include#includeusing namespace std;#define MAX 1000005 int F[ MAX ] ;void solve(){ int i ; F[ 0

2013-07-27 22:20:34 818

原创 poj2769-同余问题

http://poj.org/problem?id=2769#include#include#include#include#include#include#includeusing namespace std;#define MAX 1000005int num[ 100005 ] , judge[ MAX ] ;int main(){ int n , i , j

2013-07-27 22:08:57 889

原创 nefu84-扩展欧几里德

http://acm.nefu.edu.cn/test/problemshow.php?problem_id=84#include#include#include#include#include#include#includeusing namespace std;typedef long long INT ;INT gcd( INT a , INT b ){

2013-07-27 16:33:58 849

原创 nefu116 数的整除性

http://acm.nefu.edu.cn/test/problemshow.php?problem_id=116#include#include#include#include#include#include#includeusing namespace std;long long gcd( int a , int b ){ return b == 0 ? a

2013-07-27 14:26:08 953

原创 nefu115数的整除性

http://acm.nefu.edu.cn/test/problemshow.php?problem_id=115#include#include#include#include#include#include#includeusing namespace std;int main(){ int n ; while( scanf( "%d" , &n ) != E

2013-07-27 14:09:55 945

原创 poj1036-dp

http://poj.org/problem?id=1036题目分析:由题目很容易就能想到这道题目是DP题目。当然,它的DP方程也不难得到:       定义状态:d[i,j] 表示在时间t=i且门状态为j的时候所能取得的最大幸运值。那么相应的状态转移方程为              d[i,j] =max(d[i-1,j-1],d[i-1,j],d[i-1][j+

2013-07-27 09:54:46 1129

原创 hdu2837数论

http://acm.hdu.edu.cn/showproblem.php?pid=2837#include#include#include#include#include#include#includeusing namespace std;#define INT long long INT euler( int n){ INT ret=1,i; for (i=

2013-07-26 20:35:31 1513

原创 poj3358数论(欧拉定理)

http://poj.org/problem?id=3358(起初为分数形式)小数点进制转换原理:n / m ;n /= gcd( n , m ) ;m/= gcd( n , m ) ;n = n % m ;for( i : 0 to .....)n *= k ;bit[ i ] = n / m;(保留每一位的数值)n %= m ;题意:求n/m的小数点位的循环

2013-07-26 13:26:51 2132

原创 快速求一个大区间的所有因子之和

#include#include#include#include#include#include#include#define INT __int64 const int Max = 5000005 ;INT dp[ Max + 1 ] ;using namespace std;void init(){ for( int i = 0 ; i <= Max ; ++i

2013-07-26 09:23:20 1774

原创 n! 素因子分解

#include#include#include#include#include#include#includeusing namespace std;const int Max = 1000 ;int prime[ Max ] ;bool num[ Max ] = { true , true } ;int k = 0 ;void init(){ for( int i

2013-07-26 09:08:32 1937 2

原创 hdu1069-最长连续上升子序列

http://acm.hdu.edu.cn/showproblem.php?pid=1069#include#include#include#include#include#include#include#includeusing namespace std;#define MAX 2005 struct node { int x , y , ans ;}edge[

2013-07-26 08:33:42 1076

原创 hdu1231-最大连续子序列

http://acm.hdu.edu.cn/showproblem.php?pid=1231dp入门题#include#include#include#include#include#include#includeusing namespace std;#define MAX 10005int main(){ int dp[ MAX ] ; int n ; w

2013-07-25 22:47:15 979

原创 Foj1675数论

http://acm.fzu.edu.cn/problem.php?pid=1675首先必须知道一点数论的基本公式 (a-b) %c =0 -----> a%c=b%c首先通过大数取余求出目标数值对77的余数,然后求出要求数值之后开始到最后的数值对于77取余得到的余数,满足条件然后输出结果;进行枚举就可以了。#include#include#include#include#

2013-07-25 21:34:10 969

原创 hdu1299-Diophantus of Alexandria(分解素因子)

http://acm.hdu.edu.cn/showproblem.php?pid=1299题意:给定一个数值n,求满足1/ x + 1/ y = 1 /n的x,y 的组数,又因为x,y一定大于n 。所以设y = n + k ;带入方程得:x = n * n / k + n ;现在就变成了求x的值。又因为n一定大于k,所以转换成求n * n的分解数;因为n = p1 ^ e1 *

2013-07-23 08:44:56 1752 2

原创 poj2109-Power of Cryptography

http://poj.org/problem?id=2109题意:求a^b = p;给你b,p求a#include#includeint main(){ double n, m; while(scanf("%lf%lf", &n, &m) != EOF) printf("%.lf\n" ,pow(m, 1 / n)); return 0;

2013-07-22 21:04:32 904

原创 hdu1214-圆桌会议

http://acm.hdu.edu.cn/showproblem.php?pid=1214在直线上移动很简单,类似于冒泡排序的方法,一个数不断向上冒,直到最终位置。不难得到其需要移动的次数公式为n*(n-1)/2。其中n为总点数。那么在圆环上移动又会如何呢?应该会不一样这是我们直观的感受。事实也是如此,移动的过程是将圆环分为两段,分别移动。那么又在何处分段呢?答案是尽

2013-07-22 20:44:54 900

原创 hdu1124-Factorial

http://acm.hdu.edu.cn/showproblem.php?pid=1124题意为求n!中个位出现0个个数的最大总和;这也就意味着在中间过程中间所出现的所有情况都需要考虑,如果直接暴力,可能会TLE;但是,如果要个位出现0的话,那么就一定是2和5的乘,又因为在因式分解的过程中,2的倍数一定会出现,所以只需要考虑5就可以了。当数字为5~9时,由于阶乘的原因,一定会出现

2013-07-22 19:38:00 1041

原创 hdu1262-寻找素数对

http://acm.hdu.edu.cn/showproblem.php?pid=1262#include#include#include#include#include#include#includeusing namespace std;int judge( int n ){ for( int i = 2 ; i <= sqrt( n ) ; ++i )

2013-07-22 17:16:15 1127

原创 hdu1913-Prime Cuts

http://acm.hdu.edu.cn/showproblem.php?pid=1319#include#include#include#include#include#include#includeusing namespace std;const int MAX=1010;int prime[MAX],hash[MAX],k;void init_prime

2013-07-22 17:00:08 1127

原创 hdu2964-Prime Bases

http://acm.hdu.edu.cn/showproblem.php?pid=2964题意,给你一个整数n,现在要你分解成 n = k1 * ( 2 * 3 * ....*x1 ) + k2 * ( 2 * 3 * .... *x2 ) + ........;其中后面均为素数,且是由最小的2递增相乘;分析:首先打印素数表;然后使用数组a【】来储存到从第一个素数2到第几个素数乘积。找到

2013-07-22 16:12:50 929

原创 hdu2554-N对数的排列问题

http://acm.hdu.edu.cn/showproblem.php?pid=2554假设所有的2n个数据的位置分别从1~2n标号。现在假设其中第ai个数据(双胞胎),和bi。那么他们的位置则相差i + 1个位置;同理,那么所有n组双胞胎相差的数据sum( bi - ai ) ( i = 1 ......2n )  = 2 + 3 +4 + .........+ n + n +

2013-07-22 14:56:48 1351

原创 hdu1395-2^x mod n = 1

http://acm.hdu.edu.cn/showproblem.php?pid=1395原理为 a ^ b % n == d ;  >>>>>>  (( a % n ) ×(a % n ) ×........*(a % n ))%n == d  然后该题当n == 1 或者 n % 2 == 0 时 ,d肯定为 0 ,所以此时无解;而当n为其他值时,必有1~n - 1的余数存在,因

2013-07-22 13:58:06 1041

原创 小车问题

题目描述 Description甲、乙两人同时从A地出发要尽快同时赶到B地。出发时A地有一辆小车,可是这辆小车除了驾驶员外只能带一人。已知甲、乙两人的步行速度一样,且小于车的速度。问:怎样利用小车才能使两人尽快同时到达。输入描述 Input Description仅一行,三个整数,分别表示AB两地的距离s米(s≤2000),人的步行速度a米/秒,车的

2013-07-20 11:41:48 2012

转载 1079 回家

题目描述 Description现在是晚餐时间,而母牛们在外面分散的牧场中。 农民约翰按响了电铃,所以她们开始向谷仓走去。 你的工作是要指出哪只母牛会最先到达谷仓(在给出的测试数据中,总会有且只有一只最快的母牛)。 在挤奶的时候(晚餐前),每只母牛都在她自己的牧场上,一些牧场上可能没有母牛。 每个牧场由一条条道路和一个或多个牧场连接(可能包括自己)。 有时,两个牧场(可能是字母相同

2013-07-19 20:17:34 1279

原创 二叉树最大宽度和高度

题目描述 Description    给出一个二叉树,输出它的最大宽度和高度。输入描述 Input Description第一行一个整数n。下面n行每行有两个数,是这个二叉树连接到的节点的编号,如果没有连接到节点,则为0。输出描述 Output Description输出共一行,输出二叉树的最大宽度和高度,用

2013-07-19 16:29:19 2475

原创 蛇形矩阵

题目描述 Description小明玩一个数字游戏,取个n行n列数字矩阵(其中n为不超过100的奇数),数字的填补方法为:在矩阵中心从1开始以逆时针方向绕行,逐圈扩大,直到n行n列填满数字,请输出该n行n列正方形矩阵以及其的对角线数字之和.输入描述 Input Descriptionn(即n行n列)输出描述 Output Descri

2013-07-19 12:49:05 1435

原创 hdu2534-Score

http://acm.hdu.edu.cn/showproblem.php?pid=2534由题知,每一个数据都可以由ax +by组成;ax1 + by1 - c x2 a - d y2 == 1 ;ans = a * b - a - b ;#include#include#include#include#include#include#includeusing

2013-07-18 22:42:11 1278

原创 中国剩余定理(互质与不互质模版)

FZU1402 中国剩余定理#include #include #include using namespace std;typedef __int64 int64;int64 a[15],b[15];int64 Extend_Euclid(int64 a, int64 b, int64&x, int64& y){ if(b==0) { x=1,

2013-07-18 21:19:26 2399 1

原创 hdu1205-吃糖果

http://acm.hdu.edu.cn/showproblem.php?pid=1205鸽巢原理将题目糖果看作所需要的隔板,有n个糖果,根据鸽巢定理,就至少需要n-1个隔板;现在求出最大的糖果数,然后把其它剩余的糖果看作一个整体,看它是否大于最大糖果数-1这一个条件#include#include#include#include#include#include#in

2013-07-18 17:51:43 1146

原创 hdu1334-Perfect Cubes

http://acm.hdu.edu.cn/showproblem.php?pid=1334题意;求200以内所有满足a^ 3 == b^ 3 + c ^ 3 +d ^ 3 #include#include#include#include#include#include#includeusing namespace std;int main(){ int a , b

2013-07-18 14:35:05 1188

原创 zoj1241-Geometry Made Simple

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=241格式问题#include#include#include#include#include#includeusing namespace std;int main(){ double a , b , c ; int Case = 0 ; whil

2013-07-18 09:58:21 1020

原创 hdu1323-Perfection

http://acm.hdu.edu.cn/showproblem.php?pid=1323#include#include#include#include#include#includeusing namespace std;#define MAX 105 int num[ MAX ] ;int judge( int n ){ int sum = 0 ; f

2013-07-18 09:07:14 1060

原创 zoj1154-Niven Numbers

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=154#include#include#include#include#include#include#include#include using namespace std;int main(){ int sum , ans ; int Case ;

2013-07-18 07:59:03 943

原创 hdu1017-A Mathematical Curiosity

http://acm.hdu.edu.cn/showproblem.php?pid=1017注意格式,在每一组的结束输出一行空行,就是在输入n,m均为0时,#include#include#include#include#include#include#include#include using namespace std;int main(){ int Case

2013-07-17 22:29:27 970

2013年蓝桥杯辅导资料

2013年蓝桥杯内部购买资料,包括参考例题上面均有

2013-04-12

空空如也

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

TA关注的人

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