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
Bulls and
Cows
YouareplayingthefollowingBullsandCowsgamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessmatc
github_34333284
·
2016-04-19 11:00
POJ 3264 Balanced Lineup RMQ
65536KTotalSubmissions: 43406 Accepted: 20391CaseTimeLimit: 2000MSDescriptionForthedailymilking,FarmerJohn's N
cows
Houheshuai
·
2016-04-19 11:00
ACM
RMQ
ACM--单调栈--Bad Hair Day--POJ--3250--水
id=3250BadHairDayDescriptionSomeofFarmerJohn's N
cows
(1≤ N ≤80,000)arehavingabadhairday!
qq_26891045
·
2016-04-16 15:00
ACM
poj
day
单调栈
bad
HAIR
3250
poj 2481
Cows
树状数组or线段树
题意:给n个区间,问第i个区间是多少个区间的子区间。分析:可以吧每一个线段看成是一个点,这样的话就等价于问一个点的左上方有多少个点?这样就和Stars那题一样了。因为是求左上方有多少个点,那么把所有点按照y从大到小排列,这样就可以按照顺序求出0~x之间有多少个点,就是它左上方的点了。需要重点的处理。树状数组:#include #include #include #include usingname
hjt_fathomless
·
2016-04-16 10:00
POJ 2186 —— Popular
Cows
原题:http://poj.org/problem?id=2186题意:问有多少个点满足条件——其他所有的点都可以到达它;思路:先求强连通分量,然后反向构建DAG图,新图中的点权就是每个强连通分量所包含的点的个数(因为强连通分量中任意两点均可达);如果新图中入度=0的点超过一个就输出0,否则就输出该点的点权;Q:为什么要反向建图?A:反向建图就将问题转化成了从该点出发是否可以遍历所有的点;Q:为什
L_avender
·
2016-04-15 22:00
强连通
POJ3246-Balanced Lineup,好经典的题,做法和HDU-I hate it 一样~~
BalancedLineupTimeLimit: 5000MS MemoryLimit: 65536K CaseTimeLimit: 2000MSDescriptionForthedailymilking,FarmerJohn's N
cows
NYIST_TC_LYQ
·
2016-04-14 14:00
哭晕
做完简单线段数
却发现还有更复杂的线段数
POJ_2186_Popular
Cows
#include #include #include #include #include #include #include #include #include #include #include #include #pragmawarning(disable:4996) usingstd::cin; usingstd::cout; usingstd::endl; usingstd::string
cxy7tv
·
2016-04-13 22:00
poj
SCC
LeetCode(45)-Bulls and
Cows
题目:YouareplayingthefollowingBullsandCowsgamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessm
u010321471
·
2016-04-11 17:00
LeetCode
算法
面试
cows
bulls
POJ 2456 Aggressive
cows
AggressivecowsTimeLimit: 1000MS MemoryLimit: 65536KTotalSubmissions: 9797 Accepted: 4865DescriptionFarmerJohnhasbuiltanewlongbarn,withN(2 #include usingnamespacestd; constintmaxn=100000+10; constintIN
a2459956664
·
2016-04-10 18:00
Bulls and
Cows
Youareplayingthefollowing BullsandCows gamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessma
u014568921
·
2016-04-10 16:00
LeetCode
Bulls and
Cows
YouareplayingthefollowingBullsandCowsgamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessmatc
qdqade
·
2016-04-06 13:48
leetcode
leetcode
费波拉契问题的变形
#includeusing namespace std;int Cal(int year)//法一{if (year = 4){if ((year - cnt) > 3){
cows
小止1995
·
2016-04-06 11:23
费波拉契
算法
【杭电oj】2387 - Til the
Cows
Come Home(dijkstra)
TiltheCowsComeHomeTimeLimit: 1000MS MemoryLimit: 65536KTotalSubmissions: 40239 Accepted: 13677DescriptionBessieisoutinthefieldandwantstogetbacktothebarntogetasmuchsleepaspossiblebeforeFarmerJohnwakesh
wyg1997
·
2016-04-05 17:00
USACO 1.2-Milking
Cows
/* ID:m1590291 TASK:milk2 LANG:C++ */ #include #include #include #defineMAX5005 usingnamespacestd; structNode { intbegin; intend; }a[MAX]; boolcmp(Nodex,Nodey) { returnx.begin>T) { if(T5000)break; for
qq_28300479
·
2016-04-04 23:00
bzoj 2060: [Usaco2010 Nov]Visiting
Cows
拜访奶牛(树形DP)
2060:[Usaco2010Nov]VisitingCows拜访奶牛TimeLimit: 3Sec MemoryLimit: 64MBSubmit: 346 Solved: 253[Submit][Status][Discuss]Description经过了几周的辛苦工作,贝茜终于迎来了一个假期.作为奶牛群中最会社交的牛,她希望去拜访N(1C2).这样,在每一对奶牛之间都有一条唯一的通路.F
clover_hxy
·
2016-04-04 16:00
POJ3621 Sightseeing
Cows
题意:给定一个n(2=∑f(i)/∑w(i),变形得ans*∑w(i)-∑f(i)>=0,∑(ans*w(i))-∑f(i)>=0,∑(ans*w(i)-f(i))>=0.我们采用二分答案的方法,设二分的值为k.之后构建一个新图,边权值为k*w(i)-入点/出点f(i),如果k=ans,则无负环,用SPFA判负环即可,需要注意的是源点不要从1开始(虽然这道题数据水从1开始也能过),因为环可能和1不
Monster__Yi
·
2016-04-03 11:00
01分数规划
二分答案
最优比率生成环
SPFA判负环
poj 2186 Popular
Cows
强联通分量tarjan/Kosaraju
题目简述:n头奶牛,给出若干个欢迎关系ab,表示a欢迎b,欢迎关系是单向的,但是是可以传递的。另外每个奶牛都是欢迎他自己的。求出被所有的奶牛欢迎的奶牛的数目解法:先跑一遍taijan或Kosaraju算法。那么出度为0的强连通分量代表的就是受其他奶牛欢迎的,但是如果出度为0的强连通分量的个数大于1.那么则无解。因为将至少有两个分量里的奶牛互相不喜欢。所以我们的算法就是如果出度为0的强连通分量的个数
qq_33229466
·
2016-03-31 21:00
POJ 2481
Cows
(树状数组)
CowsTimeLimit: 3000MS MemoryLimit: 65536KTotalSubmissions: 15575 Accepted: 5200DescriptionFarmerJohn'scowshavediscoveredthattheclovergrowingalongtheridgeofthehill(whichwecanthinkofasaone-dimensionalnu
zwj1452267376
·
2016-03-30 21:00
POJ 2387-Til the
Cows
Come Home(Dijkstra+堆优化)
TiltheCowsComeHomeTimeLimit:1000MS MemoryLimit:65536KTotalSubmissions:40039 Accepted:13620DescriptionBessieisoutinthefieldandwantstogetbacktothebarntogetasmuchsleepaspossiblebeforeFarmerJohnwakesherfo
MIKASA3
·
2016-03-30 18:00
poj
dijkstra
the
Ho
cows
Come
堆优化
Til
2387
Bulls and
Cows
Youareplayingthefollowing BullsandCows gamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessma
jingmiaa
·
2016-03-30 15:00
LeetCode
C++
POJ 2186 Popular
Cows
强连通分量
E-PopularCowsTimeLimit:2000MS MemoryLimit:65536KB 64bitIOFormat:%I64d&%I64uSubmitStatusDescriptionEverycow'sdreamistobecomethemostpopularcowintheherd.InaherdofN(1 #include #include #include #inc
zp___waj
·
2016-03-29 14:00
C++
poj
图论
POJ2387 Til the
Cows
Come Home
TiltheCowsComeHomeTimeLimit: 1000MS MemoryLimit: 65536KTotalSubmissions: 39985 Accepted: 13595DescriptionBessieisoutinthefieldandwantstogetbacktothebarntogetasmuchsleepaspossiblebeforeFarmerJohnwakesh
lk951208
·
2016-03-28 21:00
dijkstra
poj 2387 Til the
Cows
Come Home
这是一个最短路径问题,求Bessie最少的开销。需要注意的是,本题是个无向图,并非有向图,存储时得注意到这个问题。用Bellman-Ford算法即可解决问题。#includeusingnamespacestd;structpoint{ intbegin; intend; intlength;}s[5000];intn,t;intan[5000];intmain(){ while(cin>>t>>n
q1916569889
·
2016-03-27 17:00
算法
最短路
poj 3186 Treats for the
Cows
动态规划
题意:n个数在一个双端队列中,每次从队首或队尾出。出的第n个数乘以n,最后加起来,求最大和。用d[i][j]代表队列中的队首元素为i,队尾元素为j的最大和。所以d[i][j]=max(d[i-1][j]+a[i-1]*(n-j+i-1),d[i][j+1]+a[i][j+1]*(n-j+i-1)),当前处理的第(n-j+i-1)个点。最后d[i][i]代表只剩第I个数时的最大值,所以得自加a[i]
zchahaha
·
2016-03-25 21:00
C++
dp
动态规划
C语言
poj
Bulls and
Cows
Youareplayingthefollowing BullsandCows gamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessma
qq_27991659
·
2016-03-25 16:00
练习一1016
He wants to know how much milk this 'median' cow gives: half of the
cows
give as much or more than the
baidu_34275752
·
2016-03-24 21:00
cf#225-C - Milking
cows
-贪心
http://codeforces.com/contest/384/problem/C这题题意就是1表示牛向右看,0表示牛向左看,怎么杀牛,能让牛看到自己同伴被杀受到的惊吓最小。贪心策略是,先杀所有向左看的牛,从最左边的0牛(看左)开始杀,这样就能保证每次杀的时候,该头牛只减少向右看的牛的牛奶,而不对其余向左看的有影响。。最后剩下所有向右看的牛也是按顺序杀就不会再损失牛奶了。。。可以证明先杀左牛或
viphong
·
2016-03-23 09:00
LeetCode.299.Bulls and
Cows
英文:Youareplayingthefollowing BullsandCows gamewithyourfriend:Youwritea4-digitsecretnumberandaskyourfriendtoguessit,eachtimeyourfriendguessesanumber,yougiveahint,thehinttellsyourfriendhowmanydigitsare
happyxuma1991
·
2016-03-22 14:00
算法题
Bulls and
Cows
Youareplayingthefollowing BullsandCows gamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessma
a342500329a
·
2016-03-18 21:00
poj 2387 Til the
Cows
Come Home(Dijkstra)
问题描述BessieisoutinthefieldandwantstogetbacktothebarntogetasmuchsleepaspossiblebeforeFarmerJohnwakesherforthemorningmilking.Bessieneedsherbeautysleep,soshewantstogetbackasquicklyaspossible.FarmerJohn'sf
qq_31237061
·
2016-03-17 22:00
LeetCode:Bulls and
Cows
BullsandCowsTotalAccepted: 22040 TotalSubmissions: 76420 Difficulty: EasyYouareplayingthefollowing BullsandCows gamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis. Eachtimeyo
itismelzp
·
2016-03-16 14:00
LeetCode
and
cows
bulls
Bzoj 1703: [Usaco2007 Mar]Ranking the
Cows
奶牛排名 传递闭包,bitset
1703:[Usaco2007Mar]RankingtheCows奶牛排名TimeLimit: 5Sec MemoryLimit: 64MBSubmit: 323 Solved: 238[Submit][Status][Discuss]Description 农夫约翰有N(1≤N≤1000)头奶牛,每一头奶牛都有一个确定的独一无二的正整数产奶率.约翰想要让这些奶牛按产奶率从高到低排序.
微弱的世界
·
2016-03-15 22:00
USACO 2016 Jan Bronze 2.Angry
Cows
愤怒的奶牛
题目描述大概的意思就是一个数轴上有n个不重复的点然后你放一个点在数轴上的某处,那么他会传递以一为半径内的所有点,然后被传递的点会继续传递,传递的半径加一,一直传递下去求能够被传递的点的个数的最大值Input第一行一个数n下面n行表示数轴上的点的位置output一行一个数,如题目所述想法01.孩子们,你们的宽搜,都是干什么吃的。。。。。。。不用我教吧。。。自己写去吧02.我们发现在一个大概长为1e9
qq_32451161
·
2016-03-07 15:00
搜索
USACO
水
[POJ2186]Popular
Cows
(强连通分量)
题目链接:http://poj.org/problem?id=2186给定n个点m条边,求某点使得其他点都有通向它的一条路径,计算这个点集的大小。强连通分解后求出度为0的连通分量的个数,如果有且仅有一个连通分量出度为1,则统计这个连通分量中点的数目。遍历所有点的出边指向的点,判断这两个点是否属于同一个连通分量,记录每个连通分量中的点的数目。1#include 2#include 3#inclu
Kirai
·
2016-03-07 11:00
[LeetCode299]Bulls and
Cows
题目:Youareplayingthefollowing BullsandCows gamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidgues
zhangbaochong
·
2016-03-06 17:00
poj3660 Cow Contest
CowContestTimeLimit: 1000MSMemoryLimit: 65536KTotalSubmissions: 8986Accepted: 5045DescriptionN (1≤ N ≤100)
cows
d_x_d
·
2016-03-06 16:00
水
A - Til the
Cows
Come Home
A-TiltheCowsComeHomeTimeLimit:1000MS MemoryLimit:65536KB 64bitIOFormat:%I64d&%I64uSubmitStatusPracticePOJ2387DescriptionBessieisoutinthefieldandwantstogetbacktothebarntogetasmuchsleepaspossibleb
huangshuai147
·
2016-03-04 08:00
POJ3660 Cow Contest(floyd算法应用)
CowContestTimeLimit: 1000MS MemoryLimit: 65536KTotalSubmissions: 8767 Accepted: 4933DescriptionN (1≤ N ≤100)
cows
mengxiang000000
·
2016-03-02 19:00
poj
floyd
3
0
6
6
哈理工1018
POJ3660
3660
Bulls and
Cows
YouareplayingthefollowingBullsandCowsgamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessmatc
KickCode
·
2016-03-01 14:20
字符串
数组
USACO 2016 Jan Gold 愤怒的奶牛(Angry
Cows
)
原题目数据正解【题目描述】奶牛Bessie设计了一个游戏:“愤怒的奶牛”。游戏原型是:有一些可爆炸的草堆分布在一条数轴的某些坐标上,玩家用弹弓把一头奶牛发射到数轴上。奶牛砸到数轴上的冲击波会引发附近的草堆爆炸,并有可能引起附近的草堆连环爆炸。游戏的目标是玩家用一头奶牛炸掉所有的草堆。有N个草堆,在数轴上不同的整点(即整数位置)x1,x2,...,xN。如果玩家把一头能量R的奶牛发射到位置x,就会引
gotojava9
·
2016-03-01 13:00
二分查找
动态规划
USACO
Bulls and
Cows
YouareplayingthefollowingBullsandCowsgamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessmatc
brucehb
·
2016-03-01 01:00
Lettcode_299_Bulls and
Cows
本文是在学习中的总结,欢迎转载但请注明出处:http://blog.csdn.net/pistolove/article/details/50768550Youareplayingthefollowing BullsandCows gamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtim
pistolove
·
2016-02-29 21:00
java
LeetCode
编程
算法
面试
USACO 2016 Jan Silver 愤怒的奶牛(Angry
Cows
)
原题目数据正解【题目描述】奶牛Bessie设计了一个游戏:“愤怒的奶牛”。游戏的原型是:有一些可爆炸的草堆分布在一条数轴的某些坐标上,玩家用弹弓把一头奶牛发射到数轴上。奶牛砸到数轴上的冲击波会引发附近的草堆爆炸。游戏的目标是玩家用一些奶牛炸掉所有的草堆。有N个草堆在数轴的不同位置,坐标为x1,x2,….,xn。如果玩家以能量R把奶牛发射到坐标x,就会引爆半径R及以内的的草堆,即坐标范围[x−R,x
gotojava9
·
2016-02-28 14:00
二分查找
USACO
UVA 10491(p326)----
Cows
and Cars
#include #include usingnamespacestd; intmain() { doublea,b,c; while(scanf("%lf%lf%lf",&a,&b,&c)==3) { doubleans1=(a/(a+b))*(b/(a+b-1-c)); //cout<
wang2147483647
·
2016-02-26 14:00
【SPOJ-AGGRCOW】【BZOJ1734】【POJ2456】Aggressive
cows
【二分】【贪心】
题意:n个房间,c头牛,将这c头牛分配进房间,使得牛之间的最小距离最大。经典二分。二分答案,枚举房间。如果房间距离大于答案,那么计数器加一。如果最后计数器不小于c,说明答案应该更大,否则更小。#include #include usingnamespacestd; constintmaxn=100005; intn,m,pos[maxn]; inlineintiread(){ intf=1
BraketBN
·
2016-02-25 14:00
二分
贪心
Leetcode 299:Bulls and
Cows
Youareplayingthefollowing BullsandCows gamewithyourfriend:Youwritedownanumberandaskyourfriendtoguesswhatthenumberis.Eachtimeyourfriendmakesaguess,youprovideahintthatindicateshowmanydigitsinsaidguessma
geekmanong
·
2016-02-24 23:00
CodeForces 283B
Cows
and Program 记忆化搜索 推导
题意:你有一个正整数序列{ai},大小为n,你还有2个变量x,y,执行以下程序:x=1;y=0 while(1){ y+=a[y];x+=a[x] if(xn)return y+=a[y];x-=a[x] if(xn)return }你的任务是得到一个序列a2,a3,⋯,an枚举i(1≤i≤n−1),令a1等于i,输出上面那个程序y的值,如果程序陷入死循环输出-1。Input第一行n。第二行n−1
huanghongxun
·
2016-02-18 16:00
搜索
数学
codeforces
推导
CodeForces 283A
Cows
and Sequence 树状数组
明天就要去GDKOI了好虚怎么办QAQ。给你一个序列,一开始只有一个0接下来有n个操作,每个操作是下面3种操作描述的一种前ai个数全部加上xi在序列末尾加上ki这个数序列末尾删去一个数(所以序列的大小会减一)。只有序列里至少有2个数才执行这个操作。做完每一步,你需要输出这个序列的和的平均数。Input第一行n接下来n行,每行第一个数为ti(1 #defineFOR(i,j,k)for(i=j;i=
huanghongxun
·
2016-02-18 16:00
codeforces
树状数组
POJ 2387 Til the
Cows
Come Home(dij+邻接矩阵)
( ̄▽ ̄)"//dijkstra算法; //这题建邻接矩阵的时候有坑(先读入边后读入点),还有重边; #include #include usingnamespacestd; constintINF=10e7; constintMAXN=2010; intk,minn; intcost[MAXN][MAXN]; intlowcost[MAXN]; boolvis[MAXN];
ATMacmer
·
2016-02-17 23:00
POJ 2456 Aggressive
cows
出口判断要注意。。wa了几次。。#include #include usingnamespacestd; intcow[100010]; intmain() { intn,c; scanf("%d%d",&n,&c); inti; for(i=1;i=mid) { distance=0; count++; } } if(count>=c) left=mid+1; else { right=mid-
qq_32995183
·
2016-02-17 22:00
poj
二分
上一页
4
5
6
7
8
9
10
11
下一页
按字母分类:
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
其他