E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
cows
poj 2456 Aggressive
cows
(二分+贪心思想)
DescriptionFarmerJohnhasbuiltanewlongbarn,withN(2 #include usingnamespacestd; inta[100010]; intmain() { intn,m; while(cin>>n>>m) { inthigh,low,mid; for(inti=0;i>a[i]; sort(a,a+n);//必须先排序 high=a[n-1]-a
Hoaresky1998
·
2016-02-16 18:00
C++
算法
ACM
Bulls and
Cows
Youareplayingthefollowing BullsandCows gamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessma
fanrong1985
·
2016-02-13 13:00
Algorithm
poj 2387 Til the
Cows
Come Home(dijkstra)
TiltheCowsComeHomeTimeLimit: 1000MS MemoryLimit: 65536KTotalSubmissions: 39132 Accepted: 13307DescriptionBessieisoutinthefieldandwantstogetbacktothebarntogetasmuchsleepaspossiblebeforeFarmerJohnwakesh
yao1373446012
·
2016-02-09 21:00
POJ 2456_Aggressive
cows
题意:给定N个位置,把C头牛分别放入,求相邻两头牛的最大距离。分析:即为求两头牛之间最小距离的最大值。二分搜索答案。代码:#include #include #include usingnamespacestd; constintmaxn=100005,INF=0x3fffffff; typedeflonglongll; intx[maxn]; intN,C; intjudge(inta) { i
Yukizzz
·
2016-02-09 09:00
Java [Leetcode 229]Bulls and
Cows
题目描述:Youareplayingthefollowing BullsandCows gamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidgu
scottwang
·
2016-02-06 13:00
Popular
Cows
(POJ No.2186)
DescriptionEverycow'sdreamistobecomethemostpopularcowintheherd.InaherdofN(1 2#include 3usingnamespacestd; 4constintMAXN=500000+10; 5//------------------------- 6voidread(int&x){ 7x=0;charch=getc
543~
·
2016-02-05 19:00
poj 2182 -Lost
Cows
-线段树-还原逆序数组
题意:给出一个数组每个元素的逆序数,还原这个数组(序号为1-n)思路:还是从逆序开始处理,对于每个位置i,如果逆序数是a[i],并且我们不考虑i之后的位置,则第i个位置的序号本应该是a[i]+1,但是如果i之后的位置还存在k个小于等于a[i]+1的数,则位置i需要改为a[i]+1+k。因此,我们从后面往前处理,每次处理只需要看之前的操作(对应操作编号i到n)是否确定了小于等于原本应该填的数(a[i
viphong
·
2016-02-04 02:00
POJ-2481-
Cows
-线段树/树状数组
http://poj.org/problem?id=2481给出n个区间输出每个区间 是多少个区间的真子集 思路:区间左端点为第一关键字,右端点第二关键字,前者升序后者降序这样对每个区间i,只需要查询Ri到n有多少个右端点就是答案, 可能有好几个区间相同,那么预处理一下最后减掉完全相同的区间即可#include #include #include #include #include #includ
viphong
·
2016-02-03 22:00
POJ 2186 Popular
Cows
(强联通)
http://poj.org/problem?id=2186PopularCowsTimeLimit: 2000MS MemoryLimit: 65536KTotalSubmissions: 23819 Accepted: 9767DescriptionEverycow'sdreamistobecomethemostpopularcowintheherd.InaherdofN(1 * *Time:
phlsheji
·
2016-02-03 10:00
POJ 2186 Popular
Cows
(强联通)
http://poj.org/problem?id=2186PopularCowsTimeLimit: 2000MS MemoryLimit: 65536KTotalSubmissions: 23819 Accepted: 9767DescriptionEverycow'sdreamistobecomethemostpopularcowintheherd.InaherdofN(1 * *Time:
phlsheji
·
2016-02-03 10:00
Balanced Lineup (POJ_3264) 线段树+区间查询
65536KTotalSubmissions: 42086 Accepted: 19775CaseTimeLimit: 2000MSDescriptionForthedailymilking,FarmerJohn's N
cows
Keeping111
·
2016-02-02 18:00
线段树
poj
区间查询
区间更新
【poj3264】 Balanced Lineup(RMQ)
DescriptionForthedailymilking,FarmerJohn's N
cows
(1≤ N ≤50,000)alwayslineupinthesameorder.OnedayFarmerJohndecidestoorganizeagameofUltimateFrisbeewithsomeofthecows.Tokeepthingssimple
Clove_unique
·
2016-02-02 15:00
RMQ
poj 3264 balanced lineup
65536KTotalSubmissions: 42075 Accepted: 19769CaseTimeLimit: 2000MSDescriptionForthedailymilking,FarmerJohn's N
cows
clover_hxy
·
2016-02-02 14:00
uva 10491
Cows
and Cars
原题:Intelevisioncontests,participantsareoftenaskedtochooseonefromasetofordoorsforexample,oneorseveralofwhichleadtodifferentprizes.Inthisproblemwewilldealwithaspecifickindofsuchacontest.Supposeyouaregiv
·
2016-01-30 17:00
概率
uva
Bulls and
Cows
leetcode
Youareplayingthefollowing BullsandCows gamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessma
sdlwlxf
·
2016-01-30 12:00
JavaScript学习:逻辑猜数游戏
二、页面代码建立一个文件bulls_and_
cows
.html,里面输入下面代码: J
北风其凉
·
2016-01-28 23:00
JavaScript
猜数字
逻辑猜数
POJ 3166 Treats for the
Cows
题目链接:http://poj.org/problem?id=3186题意:给出大小为n的数字序列,每次操作从左边或者右边去掉一个数si,总分数等于si乘于操作数i思路:每次仅可以从左边或者右边出一个数,dp[i][j](i是左边出的数的个数,j是右边出的数的个数)就只能由dp[i-1][j]以及dp[i][j-1]得出,一直递归就可以了#include #include #include #in
csdn364988181
·
2016-01-28 20:00
dp
ACM
poj
POJ 2387 —— Til the
Cows
Come Home 裸dijkstra
原题:http://poj.org/problem?id=2387题意:有T条路,n个点;给出每条路的花费,问从n到1的最小花费;注意:1、无向图;2、有重边;3、输入T n,边在前,点在后;#include #include #include #include #defineinf1e9 usingnamespacestd; constintmaxn=1100; intT,n; boolvis[
L_avender
·
2016-01-27 15:00
最短路
dijkstra
简单题
poj-2481-
Cows
DescriptionFarmerJohn’scowshavediscoveredthattheclovergrowingalongtheridgeofthehill(whichwecanthinkofasaone-dimensionalnumberline)inhisfieldisparticularlygood.FarmerJohnhasNcows(wenumberthecowsfrom1to
qq_21120027
·
2016-01-26 21:00
poj 2186 Popular
Cows
人生的第一个强连通的题诞生了~强联通缩点的理论基础感觉其实就一句话:图上的强连通是一个等价关系(如果不知道什么是等价关系的最好去看一下关系理论。再然后就是代码实现了。tarjan真乃神人也缩点什么的。。要不看看代码?这个题是求有向图中对所有点都可达的点的个数某结论是:DAG中当且仅当图中只有一个出度为0的时候才有被所有点可达的点,并且就是这个出度为0的点然后显然缩点之后的图是一个DAG,那么只要找
a1s4z5
·
2016-01-26 10:00
poj 2387 Til the
Cows
Come Home(最短路径)
题意:有n个点,给出两点之间的距离,求出从1到n的最短路径。思路:最短路径模板题。参考博客:http://blog.csdn.net/wangjian8006/article/details/7871889spfa算法详解:http://www.360doc.com/content/13/1208/22/14357424_335569176.shtmldijkstra:/* dijkstra Me
u014552756
·
2016-01-26 09:00
Bull And
Cows
packagecn.edu.xidian.sselab.hashtable;importjava.util.HashMap;importjava.util.Map;importjava.util.Set;/** * *@authorzhiyongwang *title:BullAndCows *content: *ouareplayingthefollowingBullsandCowsgamewi
wzyxidian
·
2016-01-26 00:00
Bulls and
Cows
题目链接:https://leetcode.com/problems/bulls-and-
cows
/题目描述:猜数字游戏,两个字符串,secret与guess,将guess与secret比较,找出guess
codeTZ
·
2016-01-25 21:00
LeetCode
String
hash
POJ 3186 Treats for the
Cows
题目链接:[kuangbin带你飞]专题十二基础DP1O-TreatsfortheCows题意给长度为n的序列,每次只能从首或尾取一个数,第i次取的数权值为(数值*i),求取完所有的数可以达到的最大权值。思路dp[i][j]表示左边取了i个数,右边取了j个数故dp[i][j]=max(dp[i-1][j]+a[i]*(i+j),dp[i][j-1]+a[n-j+1]*(i+j));注意当ij为0的
to_be_better
·
2016-01-24 23:00
dp
poj
78.Bulls and
Cows
Youareplayingthefollowing BullsandCows gamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessma
u010339647
·
2016-01-24 16:00
POJ 3348
Cows
(凸包+多边形面积)
http://poj.org/problem?id=3348大意:用已有的树围成最大的牧场来养牛,每头牛生活至少需要50平方米。求出能养多少头?听说此题不难,然而我因为打错了一个变量看了一晚上(外加一早上T_T)。大致思路是:用凸包确定能构造的最大多边形,然后求解凸包多边形的面积。耻辱句:最后求面积的:for(inti=2;i #include #include usingnamespacestd
theArcticOcean
·
2016-01-23 09:00
凸包
【2186】Popular
Cows
(强连通分支及其缩点)
【2186】PopularCows(强联通分支及其缩点)PopularCowsTimeLimit:2000MSMemoryLimit:65536KTotalSubmissions:28323Accepted:11459DescriptionEverycow'sdreamistobecomethemostpopularcowintheherd.InaherdofN(1#include#include
A_LeiQ
·
2016-01-22 20:02
强连通
POJ
ACM道路之图论
【2186】Popular
Cows
(强连通分支及其缩点)
【2186】PopularCows(强联通分支及其缩点)PopularCowsTimeLimit:2000MS MemoryLimit:65536KTotalSubmissions:28323 Accepted:11459DescriptionEverycow'sdreamistobecomethemostpopularcowintheherd.InaherdofN(1 #include #inc
ChallengerRumble
·
2016-01-22 20:00
Popular
Cows
-POJ2186Tarjan
TimeLimit:2000MS MemoryLimit:65536K DescriptionEverycow'sdreamistobecomethemostpopularcowintheherd.InaherdofN(1 #include #include #include #include #include #include #include usingnamespacestd; co
huayunhualuo
·
2016-01-22 17:00
POJ3621 Sightseeing
Cows
又被G++坑了一次。。。。。算了不提也罢。题意要找一个环游路线使得收益/花费最大,显然是基环,于是分数规划,判断是否有正权圈。然后弃疗发现好像不会求正权圈唉。算了,取反。改求负权圈,spfa一下就好了。#include #include #include #include #include usingnamespacestd; constintN=1000+5; constdoubleeps=1e
nlj1999
·
2016-01-18 21:00
leetcode笔记:Bulls and
Cows
一.题目描述YouareplayingthefollowingBullsandCowsgamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidgue
liyuefeilong
·
2016-01-13 21:00
LeetCode
Algorithm
C++
算法
String
POJ-2181 Jumping
Cows
(贪心)
JumpingCowsTimeLimit:1000MSMemoryLimit:65536KTotalSubmissions:7329Accepted:4404DescriptionFarmerJohn’scowswouldliketojumpoverthemoon,justlikethecowsintheirfavoritenurseryrhyme.Unfortunately,cowscannot
Dacc123
·
2016-01-07 19:00
POJ2456 Aggressive
cows
二分
DescriptionFarmerJohnhasbuiltanewlongbarn,withN(2 #include usingnamespacestd; constintmaxn=100010; ints[maxn]; intn,m; boolok(intx) { intcnt=1; inttmp=s[0]; for(inti=1;i=x){ cnt++; tmp=s[i]; } } retur
hrhguanli
·
2016-01-07 14:00
POJ2456 Aggressive
cows
二分
DescriptionFarmerJohnhasbuiltanewlongbarn,withN(2 #include usingnamespacestd; constintmaxn=100010; ints[maxn]; intn,m; boolok(intx) { intcnt=1; inttmp=s[0]; for(inti=1;i=x){ cnt++; tmp=s[i]; } } retur
hrhguanli
·
2016-01-07 14:00
USACO--Milking
Cows
MilkingCowsThreefarmersriseat5ameachmorningandheadforthebarntomilkthreecows.Thefirstfarmerbeginsmilkinghiscowattime300(measuredinsecondsafter5am)andendsattime1000.Thesecondfarmerbeginsattime700andends
lk951208
·
2016-01-01 13:00
POJ 3621 Sightseeing
Cows
(01分数规划+二分+spfa判负环)
Description给出一张有向图,求一个回路使其点权和/边权和最大(保证有回路)Input第一行为两个整数n和m表示点数和边数,之后n个整数表示n个点的点权,最后m行每行三个整数a,b,c表示a点到b点有一条权值为c的边Output输出一条回路的最大点权和/边权和值SampleInput57301010510123232345352455513522SampleOutput6.00Soluti
V5ZSQ
·
2015-12-31 13:00
POJ 2387 Til the
Cows
Come Home(spfa)
Descriptionn个点m条边,每条边有权值,问从点1到点n的最短距离Input第一行两个整数m和n表示边数和点数(1 #include #include #include #include #include usingnamespacestd; #defineINF0x3f3f3f3f #definemaxn1111 #definemaxm111111 structedge { intto;
V5ZSQ
·
2015-12-28 14:00
Bulls and
Cows
解题报告
题目链接:https://leetcode.com/problems/bulls-and-
cows
/Youareplayingthefollowing BullsandCows gamewithyourfriend
qq508618087
·
2015-12-28 11:00
LeetCode
算法
hash
【LEETCODE】299-Bulls and
Cows
YouareplayingthefollowingBullsandCowsgamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessmatc
aliceyangxi1987
·
2015-12-26 21:00
LeetCode
python
问题 O: 1.2.1 Milking
Cows
挤牛奶
问题O:1.2.1MilkingCows挤牛奶时间限制: 1Sec 内存限制: 64MB提交: 147 解决: 50题目描述三个农民每天清晨5点起床,然后去牛棚给3头牛挤奶。第一个农民在300时刻(从5点开始计时,秒为单位)给他的牛挤奶,一直到1000时刻。第二个农民在700时刻开始,在1200时刻结束。第三个农民在1500时刻开始2100时刻结束。期间最长的至少有一个农民在挤奶的连续时间为9
qq_28954601
·
2015-12-21 21:00
编程
C语言
作业
【Leetcode】Bulls and
Cows
题目链接:https://leetcode.com/problems/bulls-and-
cows
/题目:Youareplayingthefollowing BullsandCows gamewithyourfriend
yeqiuzs
·
2015-12-12 22:00
POJ 3348
Cows
(凸包+求面积)
CowsTimeLimit:2000MS MemoryLimit:65536KTotalSubmissions:7869 Accepted:3565DescriptionYourfriendtothesouthisinterestedinbuildingfencesandturningplowsharesintoswords.Inordertohelpwithhisoverseasadventur
helloiamclh
·
2015-12-12 14:00
leetcodeBulls and
Cows
//由于本人比较菜,所以先刷easy的===这道题做出虽然AC了,但是时间很慢呀,后来仔细看了一下,的确可以优化的。我是先处理值和位置都完全一样的,所以遍历了两次,其实可以完全遍历一次,遍历一次需要注意验证,当取了一个值相同位置不相同的时候,那么guess的一个数字占领了secret中一个数字,如果恰好这个secret对应的位置在guess上是值和位置都相同的,那么这里由于前面已经被占领了,所以不
u011954647
·
2015-12-11 22:00
LeetCode
【LeetCode】299 Bulls and
Cows
题目链接BullsandCows分析题目给出俩个字符串secret和guess。找出bull和cow的个数。bull:位置相同并且字符相同;cow:字符相同但是位置不同;注意这个case的输出结果:Input:“1122”“1222”Expected:“3A0B”代码stringnum2str(intnum){ if(num==0) return"0"; stringstr=""; while(n
realxuejin
·
2015-12-11 15:00
LeetCode
POJ3186:Treats for the
Cows
(区间DP)
DescriptionFJhaspurchasedN(1 #include #include usingnamespacestd; inta[2005],dp[2005][2005]; intmain() { intn,i,j,k,l,ans; while(~scanf("%d",&n)) { for(i=1;i<=n;i++) scanf("%d",&a[i]);
·
2015-12-09 10:08
poj
leetcode -- Bulls and
Cows
-- 难理解题意,要看
https://leetcode.com/problems/bulls-and-
cows
/这里要注意重复的问题。
xyqzki
·
2015-12-08 23:00
LeetCode
nyoj 211 (Floyd算法求传递闭包)
CowContest时间限制:1000 ms | 内存限制:65535 KB难度:4描述N (1≤ N ≤100)
cows
,convenientlynumbered1..N,areparticipatinginaprogrammingcontest.Asweallknow
hexianhao
·
2015-12-06 12:00
图论
POJ3186 Treats for the
Cows
DP
TreatsfortheCowsTimeLimit:1000MSMemoryLimit:65536KB64bitIOFormat:%I64d&%I64uDescriptionFJhaspurchasedN(1 #include #include #include #include usingnamespacestd; intdp[2005][2005]; inta[2005]; intmain(
qq_21057881
·
2015-12-02 20:00
LeetCode299——Bulls and
Cows
我的解法
YouareplayingthefollowingBullsandCowsgamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessmatc
booirror
·
2015-11-28 14:00
LeetCode
面试题
leetcocd_Bulls and
Cows
描述:YouareplayingthefollowingBullsandCowsgamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessm
dfb198998
·
2015-11-26 14:00
上一页
5
6
7
8
9
10
11
12
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他