上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 41 下一页

Sum

摘要: Sum时间限制:1000 ms | 内存限制:65535 KB难度:2描述Consider the natural numbers from 1 to N. By associating to each number a sign (+ or -) and calculating the value of this expression we obtain a sum S. The problem is to determine for a given sum S the minimum number N for which we can obtain S by associating sig 阅读全文
posted @ 2012-06-19 20:28 江财小子 阅读(304) 评论(0) 推荐(0) 编辑

POJ 4047Garden

摘要: 金华邀请赛题目D线段树#include <iostream>#include <cstdio>#include <cstring>using namespace std;struct node{ int l,r; int mx; int re;};node lt[800000];int n,Max;int a[200003],b[200003];void built(int l,int r,int k)//建树{ lt[k].l=l; lt[k].r=r; lt[k].re=0; if(l==r) { lt[k].mx=b[l]; return ; } in 阅读全文
posted @ 2012-05-20 08:53 江财小子 阅读(185) 评论(0) 推荐(0) 编辑

初等数论

摘要: 初等数论昨晚写到凌晨近一点,终于把自己目前会的数论知识做了下终结,最后发现原来只有这么点东西。。。路还好远O(∩_∩)O哈!一.求最大公约数:gcd(a,b)代表a,b的最大公约数,设为d;(1)朴素算法:暴力枚举咯.,先比较a,b大小,然后从1开始直到较小的那个数,算出最大可以被2数同时整除的数,即d;(2)欧几里得算法:gcd(a,b)=gcd(b,a%b);递归求解;在证明这个之前,首先得知道几个定理: 1.d=gcd(a,b)则d|ax+by; |代表的是整除;这个比较明显是正确的。 2.a|b且b|a <=> a=b; 这个也比较显然。设d=gcd(a,b);q=[a/b 阅读全文
posted @ 2012-05-03 07:16 江财小子 阅读(210) 评论(0) 推荐(0) 编辑

康托逆展开和康托展开的逆运算

摘要: 百度百科有一些说明 但很难看懂 我尽可能用简单的语言来说明学会使用康托展开后就能方便地解决一系列的问题一、康托展开对于一个集合{1,2,3,4,...,n}的从小到大排序(或者从大到小,与从小到大类似,这里只说前者)的全排列 显然它有n!项用自然数1,2,...,n!与之一一对应,这是一种对应法则。这个法则理解起来并不容易,还是用一些例子来说明吧例1 {1,2,3,4,5}的全排列,并且已经从小到大排序完毕(1)找出45231在这个排列中的顺序比4小的数有3个比5小的数有4个但4已经在之前出现过了所以是3个比2小的数有1个比3小的数有两个但2已经在之前出现过了所以是1个比1小的数有0个那么45 阅读全文
posted @ 2012-04-23 22:51 江财小子 阅读(235) 评论(0) 推荐(0) 编辑

NYOJ 102 次方求模

摘要: 描述求a的b次方对c取余的值输入第一行输入一个整数n表示测试数据的组数(n<100)每组测试只有一行,其中有三个正整数a,b,c(1=<a,b,c<=1000000000)输出输出a的b次方对c取余之后的结果样例输入32 3 53 100 1011 12345 12345样例输出3110481#include <iostream>#include <cstdio>using namespace std;int main(){ long long int a,b,c,t; int T; scanf("%d",&T); whil 阅读全文
posted @ 2012-04-23 22:29 江财小子 阅读(192) 评论(0) 推荐(0) 编辑

POJ 2387 Til the Cows Come Home(Dijkstra)

摘要: Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get back as quickly as possible. Farmer John's field has N (2 <= N <= 1000) landmarks in it, un 阅读全文
posted @ 2012-04-22 11:06 江财小子 阅读(227) 评论(0) 推荐(0) 编辑

POJ 1094 Sorting It All Out(经典拓扑,唯一排序)

摘要: DescriptionAn ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, the sorted sequence A, B, C, D implies that A < B, B < C and C < D. in this problem, we will give you a set of re 阅读全文
posted @ 2012-04-21 11:05 江财小子 阅读(242) 评论(0) 推荐(0) 编辑

POJ 3259 Wormholes(Bellman Ford 单源最短路径(可求带负权边的))

摘要: DescriptionWhile exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination at a time that is BEFORE you entered the wormhole! Each of FJ's farms comprises N (1 ≤ N ≤ 500) field 阅读全文
posted @ 2012-04-20 21:45 江财小子 阅读(209) 评论(0) 推荐(0) 编辑

HDU 1285 确定比赛名次(第一个拓扑排序题目)

摘要: 有N个比赛队(1<=N<=500),编号依次为1,2,3,。。。。,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前。现在请你编程序确定排名。Input输入有若干组,每组中的第一行为二个数N(1<=N<=500),M;其中N表示队伍的个数,M表示接着有M行的输入数据。接下来的M行数据中,每行也有两个整数P1,P2表示即P1队赢了P2队。Output给出一个符合要求的排名。输出时队伍号之间有空格,最后一名后面没有空格。其他说明:符合条 阅读全文
posted @ 2012-04-19 18:15 江财小子 阅读(526) 评论(0) 推荐(0) 编辑

hdu 1272 小希的迷宫

摘要: Problem Description上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头路)。小希现在把她的设计图给你,让你帮忙判断她的设计图是否符合她的设计思路。比如下面的例子,前两个是符合条件的,但是最后一个却有两种方法从5到达8。 Input输入包含多组数据,每组数据是一个以0 0结尾的整数 阅读全文
posted @ 2012-04-14 10:38 江财小子 阅读(162) 评论(0) 推荐(0) 编辑
上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 41 下一页