
oj
文章平均质量分 51
u010961419
这个作者很懒,什么都没留下…
展开
-
51nod-1050 循环最大字段和
N个整数组成的循环序列a[1],a[2],a[3],…,a[n],求该序列如a[i]+a[i+1]+…+a[j]的连续的子段和的最大值(循环序列是指n个数围成一个圈,因此需要考虑a[n-1],a[n],a[1],a[2]这样的序列)。当所给的整数均为负数时和为0。例如:-2,11,-4,13,-5,-2,和最大的子段为:11,-4,13。和为20。 Input第1行:整数...原创 2014-04-12 23:42:40 · 153 阅读 · 0 评论 -
boj 462
dp {i,j}=i*{i,j-1}+i*{i-1,j-1}=i*[{i,j-1}+{i-1,j-1}];#include<iostream>using namespace std;long long dp[1005][1005];//dp[i][j]表示i条入线,j条出线int main(){ for(int i=0;i<=1000;i+...原创 2013-02-14 15:54:55 · 89 阅读 · 0 评论 -
boj 16
dfs,另外用dp[k][x1][y1][x2][y2]进行标记#include<iostream>#include<cmath>using namespace std;#define N 20double G[10][10],dp[20][10][10][10][10];//棋盘;double e;double f(int x1,i...原创 2013-02-13 17:48:10 · 108 阅读 · 0 评论 -
boj 312
并查集---可能是我水过最多的算法。。。。#include<iostream>using namespace std;#define N 50005 #define M 105int colorClass[N];int father[M];int findFather(int i){ if(father[i]!=i) father[i...原创 2013-02-12 00:13:57 · 113 阅读 · 0 评论 -
boj 591
蛋疼的晚上打开一道题boj 591,发现就是辗转相除法,求系数。。。然后先是输出“Not Exist”打错为“No Exist”,后来又少写return 0;狗血。。。。。。#include<iostream>using namespace std;int judge(int max,int min,int &first,int &second)//辗...原创 2013-02-07 04:16:03 · 116 阅读 · 0 评论 -
boj 32
dp,k位的以i∈[0,9]开头的no-decreasing Num的个数为dp[k][i]=dp[k-1][i]+dp[k-1][i+1]+...+dp[k-1][9],对于输入的n只需输出dp[n+1][0]即可#include<iostream>using namespace std;#define N 66long long dp[N][10]...原创 2013-02-05 21:11:11 · 110 阅读 · 0 评论 -
boj 348
水题,读入数据时注意,开始以回车作为结束,发现坑爹,还是计数靠谱,输出格式也要注意#include<iostream>using namespace std;int main(){ int n; scanf("%d",&n); while(n!=1) { int s=0,r=0,c=0; char ch; int cnt=...原创 2013-02-05 18:42:48 · 101 阅读 · 0 评论 -
boj 317
只需寻找到连续的两个序列时,一个pawn上去消灭一个rook。但是选取哪个pawn上去的时候要根据以下原则,其实就是为了连续序列时能消灭更多的rookif(curPawnsCol[j]<curPawnsCol[j+1]) curPawnsCol[j+1]--; else curPawnsCol[j]--; 代码:#include<i...原创 2013-02-05 17:32:43 · 101 阅读 · 0 评论 -
转 POJ1734
POJ 1734(找最小环) 一道很经典的Floyd的拓展,注意第一层里的循环顺序,看懂以后你会赞叹Floyd的奇妙!题意:给出一张无向图,求一个最小环并输出路径。http://proverbs.diandian.com/post/2012-05-10/18185390#include <cstdio>#include <cstrin...原创 2013-02-04 23:33:18 · 168 阅读 · 0 评论 -
boj 24
http://acm.bupt.edu.cn/onlinejudge/newoj/showProblem/show_problem.php?problem_id=24作为一个水货,只能水过。。。找时间看下划分树和线段树等算法吧。。。#include<iostream>#include<algorithm>using namespace std;...原创 2013-02-04 17:08:22 · 86 阅读 · 0 评论 -
zoj 3160
11月19号准备做的题。。。拖了2个月。。。。http://acm.hust.edu.cn:8080/judge/contest/view.action?cid=17253#problem/G还是想清楚再敲码,不然后面再修修补补容易出错。。。#include<iostream>#include<stdio.h>using namespace std...原创 2013-01-30 14:37:46 · 80 阅读 · 0 评论 -
boj 19
Description 在一张卡片上面,有N+1个正整数,最后一个数是M,而前N个数都不超过M,设为a1, a2, a3, …, aN, 问是否存在整数x1, x2, x3, …, xN, x(N+1), 满足x1*a1 + x2*a2 +...+ xN*aN +x(N+1)*M = 1。 当确定N和M后,显然一共有M^N张不同的卡片。现在的问题是,在这所有的卡片中,有多少张满足...原创 2013-02-14 22:36:20 · 130 阅读 · 0 评论 -
boj 439
水题,用到STL map,还是得细心点,不要少写了逻辑上应该的操作。代码:#include<iostream>#include<map>using namespace std;map<int,int>ElementStore;int main(){ int n,m; scanf("%d",&n); whi...原创 2013-02-15 02:24:20 · 88 阅读 · 0 评论 -
boj 65
Description champ最近在和dalong玩一个取石子游戏,游戏规则很简单:有三堆石子,两人轮流取,每次任选两堆石子,然后从一堆中取走x(x>=1)个石子,另一堆中取走2*x个石子,最后不能取者输掉游戏,champ每一次都先取。 现在,champ告诉你初始三堆石子的数量,他想知道,自己是否有必胜的策略。你可以假定champ和dalong都足够聪明,每次都会选择...原创 2013-02-17 23:36:16 · 87 阅读 · 0 评论 -
51nod-1101 换零钱
时间限制:1 秒 空间限制:65536 KB 分值: 20N元钱换为零钱,有多少不同的换法?币值包括1 2 5分,1 2 5角,1 2 5 10 20 50 100元。 例如:5分钱换为零钱,有以下4种换法:1、5个1分2、1个2分3个1分3、2个2分1个1分4、1个5分(由于结果可能会很大,输出Mod 10^9 + 7的结果)Input输入1个数N,...原创 2014-04-12 23:32:36 · 200 阅读 · 0 评论 -
boj 321
Description There is a positive integer N, and please give us the smallest root x of equation sqrt(N)=sqrt(x)-sqrt(y) when x and y are both positive integer.Input There are several test cases ...原创 2013-02-28 19:11:11 · 134 阅读 · 0 评论 -
boj 7
DescriptionFarmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 1,000)) planks of wood, each having some integer le...原创 2013-02-28 19:02:16 · 108 阅读 · 0 评论 -
boj 462
DescriptionJyc最近在学《现代交换原理》这门传说中的北京市精品课程。本来以为很简单,但晚上在做作业时就被一道题搞的很郁闷。交换单元是交换网络最基本的部件,其有M根入线和N根出线,它的功能就是将这M根入线上的数据按一定的规则交换到N根出线上。这个单元内部连线的不同就造成出线数据的不同,因此会有许多组合。比如说下面就是最简单的两种组合。当然这种连接有一定的规则。一根入线可以连到...原创 2013-02-21 19:48:49 · 168 阅读 · 0 评论 -
boj 196
DescriptionCC lives on the tree which has N nodes.On every leaf of the tree there is an apple(leaf means there is only one branch connect this node ) .Now CC wants to get two apple ,CC can choose ...原创 2013-02-21 19:44:18 · 97 阅读 · 0 评论 -
boj 36
Fax machines use a form of compression based on run-length encoding. Run-length encoding (RLE)is a very simple form of data compression in which runs of data (that is, sequences in which the same dat...原创 2013-02-21 19:37:43 · 144 阅读 · 0 评论 -
boj 376
Descriptioncloudiris是个爱学习的好孩子,每天她都会记单词,可她一翻开单词书看到如此之多的单词就感到头疼,于是她想出了一个和别人不相同的记单词的方法。她把单词归类分成几组,每一组单词的开头几个字母都是相同的,现在她需要根据给出的这组单词找出每个单词的最短前缀来唯一的标识这个单词。例如: carburetor 和carbohydrate 的最短前缀分别是carbu和carbo ...原创 2013-02-21 18:29:43 · 118 阅读 · 0 评论 -
boj 377
Description相信大家都玩过成语接龙吧,现在我们来玩一个单词接龙的游戏。游戏是在一个单词表上进行的,我们定义单词B可以接在单词A后,当且仅当A是B的前缀且B不等于A。考察如下的单词表:i、in、ix、int,一共有i->in、i->ix、i->int、in->int共4种接法。现在给定一个单词表,求出这个单词表可以构成的最长单词串包含的单词个数。Input输入包...原创 2013-02-21 00:02:49 · 153 阅读 · 0 评论 -
boj 288
DescriptionAs is told by the olds, there is a wonderful land of girls and magic, which has a fantasy name —— Gensokyo.Today's Gensokyo is still peaceful. And a silly ice fairy Cirno wants to pla...原创 2013-02-19 00:47:37 · 102 阅读 · 0 评论 -
boj 1071
Descriptiondalong他们马上要去final了,他们这次将要坐灰机到瑞典,灰机会经过N个城市(包括起点和终点),由于这次出国机会难得,他们决定的要访问尽可能多的城市。注意这是一张往返机票,并且每个城市最多只能访问一次,除了起始点可以访问两次。现在给出N个城市,编号从1到N,并且城市从东往西排列。去时飞机只能从东往西飞不能反过来,回来时,只能从西往东不能反过来。注意必须到达最西面才能...原创 2013-02-18 15:31:11 · 93 阅读 · 0 评论 -
boj 11
Description We are familiar with the game called “Counting 24”. Now it comes a problem that we want to know whether we can figure out the exact answer with given 4 numbers only using +,-,*,/ and ...原创 2013-05-07 16:27:20 · 124 阅读 · 0 评论 -
boj 342
Descriptionxiaoming实在太好管闲事了.有一天他去参加一个舞会,这里聚集了一大堆帅哥美女,但是舞会却不是那么顺利,虽然帅哥和美女的人数都是相同的,但并不是每一位帅哥都能找到他的舞伴,原因就是有些女生只愿意接受某些男生的邀请.小明为了舞会的顺利进行,xiaoming只好厚着脸皮去和这些女生搭话,了解到了这些女生就都愿意接受哪些男生的邀请,那么剩下的工作就是要小明给这些帅哥美女们搭搭...原创 2013-05-07 00:30:45 · 135 阅读 · 0 评论 -
boj 343
DescriptionTradia最近去了趟超市,采购了好多好吃的东西,其中花花绿绿的巧克力最是诱人。为了感谢Jim前段时间对自己的帮助,Tradia决定把自己的巧克力分一些给Jim。但是Tradia也爱吃巧克力,她不想把自己全部的巧克力都给Jim,而是把巧克力平均分配,使得给Jim的总量和留给自己的总量之差最小。聪明的你能帮助她吗?Input输入包含多组测试数据。首先第一行输入一个数T(T&l...原创 2013-05-06 13:19:38 · 123 阅读 · 0 评论 -
boj 67
Description虽然没看过,但是ACMaryland知道这部电影,因为燕姿那首《我也很想他》。但今天我们不是要探讨这部电影,也不是这首歌,我们要来寻找自己的世界中心:-) 古人曾告诉我们,世界是平的。其实,每个人心中都有自己对世界的定义。经常看到一句话,我和你的世界,就像两条平行线,永远没有交集。于是,ACMaryland决定,定义这个虚拟世界为一条直线。 在这个世界里,ACMaryla...原创 2013-04-21 22:58:43 · 134 阅读 · 0 评论 -
boj 62
Description champ最近发现了一种奇怪的数,这种数是由m个连续的x后面跟上n个连续的y组成的十进制数,形如xxx...xxxyyy...yyy并且满足条件(0 < x <= 9, 0 <= y <= 9, x!=y)。 由于这种数的特性,champ把这种数叫做二部数。 现在champ有一个正整数K,他希望找到一个最小的(x,y)二部数使...原创 2013-04-21 13:24:40 · 108 阅读 · 0 评论 -
boj 77
Problem DescriptionYou are given a number 1 ≤ N ≤ 50. Every ticket has its 2N-digit number. We call a ticket lucky, if the sum of its first N digits is equal to the sum of its last N digits. You ar...原创 2013-04-19 23:36:07 · 116 阅读 · 0 评论 -
boj 86
Description在遥远的艾泽拉斯大陆上,有一个十分崇拜数字的种族。他们认为万物都是由数字组成的,而且一切的数字最后都能变成一个单独的数码。比如数字S(1990)=1+9+9+0=19,S(19)=10,S(10)=1.有一天他们从一个废墟中找到一个远古的羊皮卷轴,上面写满了密密麻麻的数字,族长认为卷轴能预言种族的未来。但是他们无法解读卷轴,你能帮助他们么?Input一开...原创 2013-04-18 16:09:05 · 482 阅读 · 0 评论 -
boj 85
Description Once upon a time,there's a boy whose name is lili.He likes to create many wonderful things.One day, he happens to come to a beautiful garden.There he picks many pretty little stones.A...原创 2013-04-18 14:21:43 · 95 阅读 · 0 评论 -
boj 75
Problem DescriptionLich Sandro investigates the magic of fire. He is standing in the center of a huge square hall with floor space one million square kilometers. The floor of the hall is paved wi...原创 2013-04-17 11:22:12 · 155 阅读 · 0 评论 -
boj 320
DescriptionRecently, Teoy bought some matches of different length. He knew that he could use these matches to form a triangle. But soon he got tired of it. Now he wanted to reckon the number ...原创 2013-04-15 22:11:24 · 93 阅读 · 0 评论 -
boj 316
Descriptionykwd's password is a number sequence. Every number in this sequence is no less than 0 and no larger than 255, and without leading zeros. ykwd wrote his password down ,but he didn't add s...原创 2013-03-21 13:00:26 · 109 阅读 · 0 评论 -
boj 10
Description There are n cells in a sequence. You can use three kinds of colors, red , pink , green to paint these cells , one cell with only one kind of color . Promising that any two adjacent ce...原创 2013-03-18 19:58:36 · 165 阅读 · 0 评论 -
boj 672
DescriptionAs the title suggest, this problem is yet another boring stone game.There are N piles of stones, Alice and Bob take turns to take away stones from the game, Alice plays first. Each ti...原创 2013-03-04 23:38:39 · 161 阅读 · 0 评论 -
boj 81
DescriptionCreating the stars is a boring job, the God also felt boring to do that. To make the creating more interesting, when created a star which had a mass value, the God put it at a position o...原创 2013-04-22 22:00:42 · 96 阅读 · 0 评论 -
boj 590
[Description]teoy和3230391在915机房里发现了一块尺寸为n*m的巧克力,两个人互不想让,于是他们打算通过游戏来把这块巧克力瓜分掉。规则是两个人轮流吃巧克力,每次吃掉一个方块的巧克力时,它右下方的巧克力方块都可以他被吃掉。但是,谁把左上角的方块吃掉,谁就必须请对方一个大果粒。并且两人都不能中途退出游戏。由于是3230391先发现的巧克力,所以3030391先吃巧克力。假...原创 2013-04-22 22:08:31 · 282 阅读 · 0 评论 -
boj 510
DescriptionEmployees of Baidu like to play a game called Making Numbers. It goes like this: there are two players in the game, one is called little A, the other little B. There are some cards with a ...原创 2013-04-23 20:18:50 · 124 阅读 · 0 评论