- 博客(40)
- 资源 (2)
- 收藏
- 关注
原创 51nod 1008 N的阶乘 mod P
输入N和P(P为质数),求N! Mod P = ? (Mod 就是求模 %)例如:n = 10, P = 11,10! = 36288003628800 % 11 = 10Input两个数N,P,中间用空格隔开。(N < 10000, P < 10^9)Output输出N! mod P的结果。Input示例10 11Output示例...
2016-11-30 20:41:56 551
原创 51nod 1005 大数加法
给出2个大整数A,B,计算A+B的结果。Input第1行:大数A第2行:大数B(A,B的长度 <= 10000 需注意:A B有可能为负数)Output输出A + BInput示例68932147586468711654886Output示例537643802472 纯粹的模拟,主要分一下几种情况:首先判断两个大数是...
2016-11-30 19:24:00 248
原创 51nod 1072 威佐夫游戏
有2堆石子。A B两个人轮流拿,A先拿。每次可以从一堆中取任意个或从2堆中取相同数量的石子,但不可不取。拿到最后1颗石子的人获胜。假设A B都非常聪明,拿石子的过程中不会出现失误。给出2堆石子的数量,问最后谁能赢得比赛。例如:2堆石子分别为3颗和5颗。那么不论A怎样拿,B都有对应的方法拿到最后1颗。Input第1行:一个数T,表示后面用作输入测试的数的数量。(1 &...
2016-11-27 21:52:20 321
原创 51nod 1185 威佐夫游戏 V2
有2堆石子。A B两个人轮流拿,A先拿。每次可以从一堆中取任意个或从2堆中取相同数量的石子,但不可不取。拿到最后1颗石子的人获胜。假设A B都非常聪明,拿石子的过程中不会出现失误。给出2堆石子的数量,问最后谁能赢得比赛。例如:2堆石子分别为3颗和5颗。那么不论A怎样拿,B都有对应的方法拿到最后1颗。Input第1行:一个数T,表示后面用作输入测试的数的数量。(1 <...
2016-11-27 21:50:35 448
原创 HDU 1241 Oil Deposits (DFS)
DescriptionThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid
2016-11-26 17:38:46 166
原创 POJ 3126 Prime Path (BFS)
DescriptionThe ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices. — It
2016-11-26 12:26:27 208
原创 POJ1426 Find The Multiple (BFS | DFS)
Find The MultipleTime Limit:1000MS Memory Limit:10000KB 64bit IO Format:%lld & %lluDescriptionGiven a positive integer n, write a program to find out a nonzero multiple m of
2016-11-26 09:56:16 233
原创 HDU2088 Box of Bricks
Box of BricksTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15483 Accepted Submission(s): 5131Problem DescriptionLittle Bob
2016-11-25 22:07:20 320
原创 poj 3006 Dirichlet's Theorem on Arithmetic Progressions
DescriptionIf a and d are relatively prime positive integers, the arithmetic sequence beginning with a and increasing by d, i.e., a, a + d, a + 2d, a + 3d, a + 4d, ..., contains infinitely man
2016-11-25 16:56:36 180
原创 poj 1004 Financial Management
睡题一枚,不过double不能够过#include int main(){ float a; float aver = 0.; for(int i = 0; i < 12; i ++){ scanf("%f",&a); aver += a; } aver /= 12; printf("$%.2f\n",aver); return 0;
2016-11-24 21:51:44 220
原创 HDU2060 Snooker
SnookerTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10607 Accepted Submission(s): 4515Problem Descriptionbackground:Phil
2016-11-23 20:15:34 362
原创 poj2251 Dungeon Master (BFS)
Dungeon MasterTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%lld & %lluDescriptionYou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon
2016-11-22 20:08:08 216
原创 HDU2057 A+B Again
A + B AgainProblem DescriptionThere must be many A + B problems in our HDOJ , now a new one is coming.Give you two hexadecimal integers , your task is to calculate the sum of them,and print
2016-11-22 18:50:05 239
原创 HDU1253 胜利大逃亡 (BFS)
胜利大逃亡Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescriptionIgnatius被魔王抓走了,有一天魔王出差去了,这可是Ignatius逃亡的好机会. 魔王住在一个城堡里,城堡是一个A*B*C的立方体,可以被表示成A个B*C的矩阵,刚开
2016-11-22 11:52:36 253
原创 HDU2717 Catch That Cow (BFS)
Catch That CowTime Limit:2000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch he
2016-11-22 10:49:26 211
原创 poj1601 青蛙的约会 (扩展欧几里得)
Description两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰...
2016-11-21 11:15:46 435
原创 HDU1576 A/B (扩展欧几里得)
Description要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。Input数据的第一行是一个T,表示有T组数据。 每组数据有两个数n(0 <= n < 9973)和B(1 <= B <= 10^9)。Output对应每组数据输出(A/B)%9973。...
2016-11-21 10:58:26 319
原创 HDU 2055 An easy problem
An easy problemTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 21733 Accepted Submission(s): 14359Problem Descriptionwe defin
2016-11-19 19:42:58 422
原创 HDU2053 Switch Game
Switch GameTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 16266 Accepted Submission(s): 9942Problem DescriptionThere are man
2016-11-19 19:32:04 300 1
原创 HDU2709 Sumsets
SumsetsTime Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2484 Accepted Submission(s): 1001Problem DescriptionFarmer John comman
2016-11-18 22:00:53 269
原创 HDU2051 Bitset
BitsetTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 21100 Accepted Submission(s): 15644Problem DescriptionGive you a number
2016-11-17 21:52:11 354
原创 HDU2049 不容易系列之(4)——考新郎
不容易系列之(4)——考新郎Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 33752 Accepted Submission(s): 12335Problem Description国庆期间,省城HZ
2016-11-17 21:34:36 253
原创 错排公式
错排问题 就是一种递推式,不过它比较著名且常用,所以要熟记!方法一: n各有序的元素应有n!种不同的排列。如若一个排列式的所有的元素都不在原来的位置上,则称这个排列为错排。任给一个n,求出1,2,……,n的错排个数Dn共有多少个。递归关系式为:D(n)=(n-1)(D(n-1)+D(n-2))D(1)=0,D(2)=1可以得到:错排公式为 f(n) = n![1-1/1!+1/2!...
2016-11-17 21:06:21 1023
原创 关于邻接矩阵的拓扑排序
#include <stdio.h>#include <stdlib.h>#define MAX 20int indegree[MAX];//用来计算所有节点的入度之和typedef int AdjMatrix[MAX][MAX];typedef struct{ int vexnum,arcnum; AdjMatrix arcs...
2016-11-17 20:59:40 4618 2
原创 关于邻接表的拓扑排序
算法思想如下:利用邻接表存储图,先设一个辅助数组indegree[]来计算所有节点的入度;首先把入度为零的节点入栈,当栈不为空时,把栈中的元素出栈,然后删除输出元素为弧尾的所有弧,并判断相应节点的入度是否为零,为零,则压入栈中。重复执行,直到栈空。 #include <stdio.h>#include <stdlib.h>#define MAX 30i...
2016-11-17 20:54:51 5968 5
原创 HDU2041 超级楼梯
超级楼梯Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 51940 Accepted Submission(s): 26567Problem Description有一楼梯共M级,刚开始时你在第一级,若
2016-11-17 20:46:07 639
原创 扩展欧几里德算法
int gcd(int a,int b){ int t,d; if(b==0) { x=1; y=0; //不明处1return a; } d=gcd(b,a%b); t=x; x=y; y=t-(a/b)*y; //不明处2return d;} 扩展欧几...
2016-11-15 19:36:05 309
原创 克鲁斯卡尔算法
设N=(V,{E})是连通网 1)令最小生成树的初始状态为只有n个顶点而无边的非连通图T=(V, {}),图中每个顶点自成一个连通分量; 2)在E中选择代价最小的边,若该边依附的顶点落在T中不同的连通分量上,则将此边加入到T中,否则舍去此边而选择下一条代价最小的边; 3)反复执行第2)步,直至T中所有顶点都在同一连通分量
2016-11-15 18:18:21 606
原创 HDU2048神,上帝以及老天爷
神、上帝以及老天爷Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 35392 Accepted Submission(s): 14499Problem DescriptionHDU 2006'10 AC
2016-11-14 18:02:03 314
原创 HDU1003 Max Sum
Max SumTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 225244 Accepted Submission(s): 52990Problem DescriptionGiven a sequenc
2016-11-14 16:53:39 211
原创 邻接表的深度优先遍历以及广度优先遍历
#include #include #define MAX 20int visited[20];typedef struct ArcNode{ int adjvex; struct ArcNode *nextarc;}ArcNode,*LinkNode;typedef struct{ char data; ArcNode *firstarc;}VNode,AdjList[
2016-11-13 17:25:31 4846
原创 邻接矩阵的深度优先遍历(递归以及非递归),广度优先遍历
#include #include #define MAX_VERTEX_NUM 20typedef int AdjMatrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM];typedef struct{ int vexnum,arcnum; char vexs[MAX_VERTEX_NUM]; AdjMatrix arc;}MGraph;typedef s
2016-11-13 17:24:34 5072
原创 普里姆算法
普里姆算法的基本思想如下:假设N={V,{E}}是连通网,TE是N上最小生成树中边的集合。从U={u}开始,TE={}开始,重复执行下述操作:在所有的u属于U,v属于V-U的边(u,v)的边中找到权值最小的一条边,并且并入TE,同时u并入U,直到U=V;先设一个辅助数组closedge[MAX],初始时先把第一个结点存入closedge[i].adjvex,令closedge数组中adjv
2016-11-13 17:20:09 1054
原创 poj 1013 Counterfeit Dollar
Counterfeit DollarTime Limit:1000MS Memory Limit:10000KB 64bit IO Format:%lld & %lluDescriptionSally Jones has a dozen Voyageur silver dollars. However, only eleven of the coin
2016-11-12 10:39:08 211
原创 poj 1850 Code
CodeTime Limit:1000MS Memory Limit:30000KB 64bit IO Format:%lld & %lluDescriptionTransmitting and memorizing information is a task that requires different coding systems for
2016-11-05 17:12:19 193
原创 poj 3252 Round Numbers
C - Round NumbersTime Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %lluSubmit StatusDescriptionThe cows, as you know, have no fingers or thumbs and thus are
2016-11-05 17:02:06 265
原创 邻接表存储图
#include #include #define MAX_VERTEX_NUM 20typedef struct ArcNode{ int Adjvex;//存储所指顶点的位置 struct ArcNode *nextarc;//指向下一结点}ArcNode;typedef struct VNode{ char data;//存储结点 ArcNode *firstarc;//
2016-11-02 20:24:33 253
原创 邻接矩阵存储图
#include #include #define MAX_VERTEX_NUM 20typedef int AdjMatrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM];typedef struct{ AdjMatrix arcs;//定义一个指向二维数组的变量 int vexnum,arcnum;//图当前的顶点数和边数 char vexs[MAX_VER
2016-11-02 19:27:23 501
转载 母函数知识点
母函数(Generating function)详解 — TankyWoo母函数(Generating function)详解— Tanky Woo在数学中,某个序列的母函数(Generating function,又称生成函数)是一种形式幂级数,其每一项的系数可以提供关于这个序列的信息。使用母函数解决问题的方法称为母函数方法。母函数可分为很多种,包括普通母函数、指数母函数、L级数...
2016-11-01 15:53:46 255
原创 HDU 2082
找单词Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6462 Accepted Submission(s): 4524Problem Description假设有x1个字母A, x2个字母B,....
2016-11-01 15:46:49 183
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人