自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Time flies

+++++++++++++++++++++++++++++++++

  • 博客(15)
  • 收藏
  • 关注

原创 hdu2824筛选法欧拉函数+求和

hdu2824筛选版本的欧拉公式模板#include#define MAX 3000000using namespace std;__int64 E[MAX+10];void init() //模板 { int i,j; memset(E,0,sizeof(E)); E[1]=1; for(i=2;i<=

2012-08-18 21:45:51 2676

原创 扩展欧几里德

在辗转相除gcd(a,b)的基础上加以扩展可以得到使等式 a*x+b*y=1 成立的解#includeusing namespace std;int x,y;int gcd(int a, int b){ return b == 0 ? a : gcd(b, a % b);}int exgcd(int a,int b,int &x,int &y){

2012-08-18 17:14:23 807

原创 欧拉函数

欧拉函数:求小于n且与n互质(最大公约数为1)的数的个数#includeint Euler(int x){ int i,sum=x; for(i=2;i*i<=x;i++) { if(x%i==0) { sum-=sum/i; //不是很明白,为什么不是sum-=x/i ——参考因数分解 while(x%i==0) x/=i;

2012-08-18 14:04:45 1546

原创 hdu1385Minimum Transport Cost-floyd+打印路径

hdu1385肚子好饿!#include#include#include#define M 500#define INF 1000000000using namespace std;int mp[M][M],path[M][M],fee[M];int main(){ int n,a,b,i,j,k,min; while(scanf("%d

2012-08-16 17:54:41 803

原创 pku3083Children of the Candy Corn-模拟+bfs

pku3083Children of the Candy Corn模拟的部分写了一下午写bfs的时候还不知道什么是bfs……然后去写bfs模板题(记录在前两篇博客里)然后贴bfs完成后就一直Runtime Error。。。因为开的数组是 mp[40][40] ,然后数据里正好有 40*40 就杯具的Runtime Error了十多次#includ

2012-08-16 15:50:45 649 2

原创 hdu1072 nightmare

hdu1072 nightmare……跟hdu1242有些不同走过的路可以返回所以不要标记,换炸弹的倒计时限制队列的增长#include#include#includeusing namespace std;int mp[10][10],m,n,Sx,Sy,Dx,Dy,flag,dir[4][2]={{0,1},{0,-1},{1,0},{-1,0

2012-08-16 14:58:08 698

原创 hdu1242 Rescue

hdu1242 Rescue广搜的模板弄明白之后就觉得……太简单了#include#includeusing namespace std;char mp[201][201];int m,n,dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};struct point{ int x,y,step; friend bo

2012-08-16 13:08:51 819

原创 优先队列

在普通队列的基础上 以权值大小执行进出队列的操作#include#includeusing namespace std;struct point{ int x,y,step; friend bool operator <(point t1,point t2) { // return t1.step>t2.step; //从小到大 return t1

2012-08-16 11:00:02 557

原创 PKU2488 A Knight`s Journey--DFS

PKU2488莫名其妙的过了……1.棋盘的布局2.输出顺序3.dir数组表示的方向#include#include#includeusing namespace std;int m,n,flag,dir[8][2]={{-1,-2},{1,-2},{-2,-1},{2,-1},{-2,1},{2,1},{-1,2},{1,2}};

2012-08-14 13:20:08 949

原创 hdu2073-无限的路

hdu2073几何简单题#include#include#includeusing namespace std;struct point{ int x,y;};double ans(point P1,point P2){ if((P1.x+P1.y)==(P2.y+P2.x)) return sqrt((P1.x-P2.x)*(P1.x-P2.x

2012-08-13 20:28:28 5076

原创 FOJ2013-最大子段和

FOJ2013限定子段长度最短为m,,贴个我的超时代码Time Limit Exceed 哈哈方法和 hdu1003 一样#include#includeusing namespace std;int num[1000001],n,m;int getn(int x){ int i,ret=0; for(i=x;i>x-m;i--) ret+=n

2012-08-13 15:46:51 868

原创 pku3041-Asteroids 最小点覆盖

pku3041-Asteroids把行列看成点再用匈牙利算法过#include#include#includeusing namespace std;bool mp[500][500],visit[500];int link[500];int m,n;bool find(int x){ int i; for(i=1;i<=n;i++) {

2012-08-13 13:25:19 913

原创 pku1942-Paths on a Grid

本质上是组合数公式 一开始是用搜索模拟 太慢了pku1942Runtime Error#include#includeusing namespace std;__int64 dfs(__int64 x,__int64 y){ if(x==1||y==1) return 1; return dfs(x-1,y)+dfs(x,y-1);}int ma

2012-08-13 11:59:29 648

原创 hdu1342&poj2245Lotto - dfs

hud1342dfs第二题 不怎么熟练看了别人的代码//hdu 1342 poj2245#include#includeusing namespace std;int ans[6],S[20];void dfs(int k,int next,int n){ int i,j; if(n==7) { for(i=1;i<=6;i++)

2012-08-12 18:30:45 789

原创 hdu1010-dfs回溯

回溯回溯回溯回溯回溯回溯回溯hdu1010#include#includeint abs(int x){ return x<0? -1*x:x;}int m,n,T,mp[10][10],Sx,Sy,Dx,Dy,flag,dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};void dfs(int x,int y,int t)

2012-08-12 12:11:40 887 1

空空如也

空空如也

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

TA关注的人

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