题目

链接:https://ac.nowcoder.com/acm/contest/28537/N
来源:牛客网

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld

题目描述

Farmer John’s N (1 <= N <= 100,000) cows, conveniently numbered 1…N, are once again standing in a row. Cow i has height Hi (1 <= Hi <= 1,000,000).
Each cow is looking to her left toward those with higher index numbers. We say that cow i ‘looks up’ to cow j if i < j and Hi < Hj. For each cow i, FJ would like to know the index of the first cow in line looked up to by cow i.
Note: about 50% of the test data will have N <= 1,000.

输入描述:

* Line 1: A single integer: N
* Lines 2..N+1: Line i+1 contains the single integer: Hi

输出描述:

* Lines 1..N: Line i contains a single integer representing the smallest index of a cow up to which cow i looks. If no such cow exists, print 0.

示例1

输入

6
3
2
6
1
1
2

输出

3
3
0
6
6
0

说明

FJ has six cows of heights 3, 2, 6, 1, 1, and 2.
Cows 1 and 2 both look up to cow 3; cows 4 and 5 both look up to cow 6; and cows 3 and 6 do not look up to any cow.

题解

这道题目可以使用单调栈,

使用方法一:

方法类似于学姐讲的滑动窗口

我认为方法为:适时丢弃,

本来暴力就是n^2,但是由于适时地删除,所以时间复杂度立马就降到了n

丢弃内容: 遇到一个高度的奶牛,看我的栈里面的内容,从小往大比较,如果大于栈中的奶牛,那么就删除栈顶的,继续比,

#mermaid-svg-TiuWbOwaHKOTrQ5n .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n .label text{fill:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n .node rect,#mermaid-svg-TiuWbOwaHKOTrQ5n .node circle,#mermaid-svg-TiuWbOwaHKOTrQ5n .node ellipse,#mermaid-svg-TiuWbOwaHKOTrQ5n .node polygon,#mermaid-svg-TiuWbOwaHKOTrQ5n .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-TiuWbOwaHKOTrQ5n .node .label{text-align:center;fill:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n .node.clickable{cursor:pointer}#mermaid-svg-TiuWbOwaHKOTrQ5n .arrowheadPath{fill:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-TiuWbOwaHKOTrQ5n .flowchart-link{stroke:#333;fill:none}#mermaid-svg-TiuWbOwaHKOTrQ5n .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-TiuWbOwaHKOTrQ5n .edgeLabel rect{opacity:0.9}#mermaid-svg-TiuWbOwaHKOTrQ5n .edgeLabel span{color:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-TiuWbOwaHKOTrQ5n .cluster text{fill:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-TiuWbOwaHKOTrQ5n .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-TiuWbOwaHKOTrQ5n text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-TiuWbOwaHKOTrQ5n .actor-line{stroke:grey}#mermaid-svg-TiuWbOwaHKOTrQ5n .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n .sequenceNumber{fill:#fff}#mermaid-svg-TiuWbOwaHKOTrQ5n #sequencenumber{fill:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n #crosshead path{fill:#333;stroke:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n .messageText{fill:#333;stroke:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-TiuWbOwaHKOTrQ5n .labelText,#mermaid-svg-TiuWbOwaHKOTrQ5n .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-TiuWbOwaHKOTrQ5n .loopText,#mermaid-svg-TiuWbOwaHKOTrQ5n .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-TiuWbOwaHKOTrQ5n .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-TiuWbOwaHKOTrQ5n .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-TiuWbOwaHKOTrQ5n .noteText,#mermaid-svg-TiuWbOwaHKOTrQ5n .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-TiuWbOwaHKOTrQ5n .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-TiuWbOwaHKOTrQ5n .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-TiuWbOwaHKOTrQ5n .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-TiuWbOwaHKOTrQ5n .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-TiuWbOwaHKOTrQ5n .section{stroke:none;opacity:0.2}#mermaid-svg-TiuWbOwaHKOTrQ5n .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-TiuWbOwaHKOTrQ5n .section2{fill:#fff400}#mermaid-svg-TiuWbOwaHKOTrQ5n .section1,#mermaid-svg-TiuWbOwaHKOTrQ5n .section3{fill:#fff;opacity:0.2}#mermaid-svg-TiuWbOwaHKOTrQ5n .sectionTitle0{fill:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n .sectionTitle1{fill:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n .sectionTitle2{fill:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n .sectionTitle3{fill:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-TiuWbOwaHKOTrQ5n .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-TiuWbOwaHKOTrQ5n .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-TiuWbOwaHKOTrQ5n .grid path{stroke-width:0}#mermaid-svg-TiuWbOwaHKOTrQ5n .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-TiuWbOwaHKOTrQ5n .task{stroke-width:2}#mermaid-svg-TiuWbOwaHKOTrQ5n .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-TiuWbOwaHKOTrQ5n .taskText:not([font-size]){font-size:11px}#mermaid-svg-TiuWbOwaHKOTrQ5n .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-TiuWbOwaHKOTrQ5n .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-TiuWbOwaHKOTrQ5n .task.clickable{cursor:pointer}#mermaid-svg-TiuWbOwaHKOTrQ5n .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-TiuWbOwaHKOTrQ5n .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-TiuWbOwaHKOTrQ5n .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-TiuWbOwaHKOTrQ5n .taskText0,#mermaid-svg-TiuWbOwaHKOTrQ5n .taskText1,#mermaid-svg-TiuWbOwaHKOTrQ5n .taskText2,#mermaid-svg-TiuWbOwaHKOTrQ5n .taskText3{fill:#fff}#mermaid-svg-TiuWbOwaHKOTrQ5n .task0,#mermaid-svg-TiuWbOwaHKOTrQ5n .task1,#mermaid-svg-TiuWbOwaHKOTrQ5n .task2,#mermaid-svg-TiuWbOwaHKOTrQ5n .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-TiuWbOwaHKOTrQ5n .taskTextOutside0,#mermaid-svg-TiuWbOwaHKOTrQ5n .taskTextOutside2{fill:#000}#mermaid-svg-TiuWbOwaHKOTrQ5n .taskTextOutside1,#mermaid-svg-TiuWbOwaHKOTrQ5n .taskTextOutside3{fill:#000}#mermaid-svg-TiuWbOwaHKOTrQ5n .active0,#mermaid-svg-TiuWbOwaHKOTrQ5n .active1,#mermaid-svg-TiuWbOwaHKOTrQ5n .active2,#mermaid-svg-TiuWbOwaHKOTrQ5n .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-TiuWbOwaHKOTrQ5n .activeText0,#mermaid-svg-TiuWbOwaHKOTrQ5n .activeText1,#mermaid-svg-TiuWbOwaHKOTrQ5n .activeText2,#mermaid-svg-TiuWbOwaHKOTrQ5n .activeText3{fill:#000 !important}#mermaid-svg-TiuWbOwaHKOTrQ5n .done0,#mermaid-svg-TiuWbOwaHKOTrQ5n .done1,#mermaid-svg-TiuWbOwaHKOTrQ5n .done2,#mermaid-svg-TiuWbOwaHKOTrQ5n .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-TiuWbOwaHKOTrQ5n .doneText0,#mermaid-svg-TiuWbOwaHKOTrQ5n .doneText1,#mermaid-svg-TiuWbOwaHKOTrQ5n .doneText2,#mermaid-svg-TiuWbOwaHKOTrQ5n .doneText3{fill:#000 !important}#mermaid-svg-TiuWbOwaHKOTrQ5n .crit0,#mermaid-svg-TiuWbOwaHKOTrQ5n .crit1,#mermaid-svg-TiuWbOwaHKOTrQ5n .crit2,#mermaid-svg-TiuWbOwaHKOTrQ5n .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-TiuWbOwaHKOTrQ5n .activeCrit0,#mermaid-svg-TiuWbOwaHKOTrQ5n .activeCrit1,#mermaid-svg-TiuWbOwaHKOTrQ5n .activeCrit2,#mermaid-svg-TiuWbOwaHKOTrQ5n .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-TiuWbOwaHKOTrQ5n .doneCrit0,#mermaid-svg-TiuWbOwaHKOTrQ5n .doneCrit1,#mermaid-svg-TiuWbOwaHKOTrQ5n .doneCrit2,#mermaid-svg-TiuWbOwaHKOTrQ5n .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-TiuWbOwaHKOTrQ5n .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-TiuWbOwaHKOTrQ5n .milestoneText{font-style:italic}#mermaid-svg-TiuWbOwaHKOTrQ5n .doneCritText0,#mermaid-svg-TiuWbOwaHKOTrQ5n .doneCritText1,#mermaid-svg-TiuWbOwaHKOTrQ5n .doneCritText2,#mermaid-svg-TiuWbOwaHKOTrQ5n .doneCritText3{fill:#000 !important}#mermaid-svg-TiuWbOwaHKOTrQ5n .activeCritText0,#mermaid-svg-TiuWbOwaHKOTrQ5n .activeCritText1,#mermaid-svg-TiuWbOwaHKOTrQ5n .activeCritText2,#mermaid-svg-TiuWbOwaHKOTrQ5n .activeCritText3{fill:#000 !important}#mermaid-svg-TiuWbOwaHKOTrQ5n .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-TiuWbOwaHKOTrQ5n g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-TiuWbOwaHKOTrQ5n g.classGroup text .title{font-weight:bolder}#mermaid-svg-TiuWbOwaHKOTrQ5n g.clickable{cursor:pointer}#mermaid-svg-TiuWbOwaHKOTrQ5n g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-TiuWbOwaHKOTrQ5n g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-TiuWbOwaHKOTrQ5n .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-TiuWbOwaHKOTrQ5n .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-TiuWbOwaHKOTrQ5n .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-TiuWbOwaHKOTrQ5n .dashed-line{stroke-dasharray:3}#mermaid-svg-TiuWbOwaHKOTrQ5n #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-TiuWbOwaHKOTrQ5n #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-TiuWbOwaHKOTrQ5n #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-TiuWbOwaHKOTrQ5n #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-TiuWbOwaHKOTrQ5n #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-TiuWbOwaHKOTrQ5n #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-TiuWbOwaHKOTrQ5n #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-TiuWbOwaHKOTrQ5n #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-TiuWbOwaHKOTrQ5n .commit-id,#mermaid-svg-TiuWbOwaHKOTrQ5n .commit-msg,#mermaid-svg-TiuWbOwaHKOTrQ5n .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-TiuWbOwaHKOTrQ5n .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-TiuWbOwaHKOTrQ5n .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-TiuWbOwaHKOTrQ5n g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-TiuWbOwaHKOTrQ5n g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-TiuWbOwaHKOTrQ5n g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-TiuWbOwaHKOTrQ5n g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-TiuWbOwaHKOTrQ5n g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-TiuWbOwaHKOTrQ5n .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-TiuWbOwaHKOTrQ5n .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-TiuWbOwaHKOTrQ5n .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-TiuWbOwaHKOTrQ5n .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-TiuWbOwaHKOTrQ5n .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-TiuWbOwaHKOTrQ5n .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-TiuWbOwaHKOTrQ5n .edgeLabel text{fill:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-TiuWbOwaHKOTrQ5n .node circle.state-start{fill:black;stroke:black}#mermaid-svg-TiuWbOwaHKOTrQ5n .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-TiuWbOwaHKOTrQ5n #statediagram-barbEnd{fill:#9370db}#mermaid-svg-TiuWbOwaHKOTrQ5n .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-TiuWbOwaHKOTrQ5n .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-TiuWbOwaHKOTrQ5n .statediagram-state .divider{stroke:#9370db}#mermaid-svg-TiuWbOwaHKOTrQ5n .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-TiuWbOwaHKOTrQ5n .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-TiuWbOwaHKOTrQ5n .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-TiuWbOwaHKOTrQ5n .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-TiuWbOwaHKOTrQ5n .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-TiuWbOwaHKOTrQ5n .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-TiuWbOwaHKOTrQ5n .note-edge{stroke-dasharray:5}#mermaid-svg-TiuWbOwaHKOTrQ5n .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-TiuWbOwaHKOTrQ5n .error-icon{fill:#522}#mermaid-svg-TiuWbOwaHKOTrQ5n .error-text{fill:#522;stroke:#522}#mermaid-svg-TiuWbOwaHKOTrQ5n .edge-thickness-normal{stroke-width:2px}#mermaid-svg-TiuWbOwaHKOTrQ5n .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-TiuWbOwaHKOTrQ5n .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-TiuWbOwaHKOTrQ5n .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-TiuWbOwaHKOTrQ5n .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-TiuWbOwaHKOTrQ5n .marker{fill:#333}#mermaid-svg-TiuWbOwaHKOTrQ5n .marker.cross{stroke:#333}

:root { --mermaid-font-family: "trebuchet ms", verdana, arial;}
#mermaid-svg-TiuWbOwaHKOTrQ5n {
color: rgba(0, 0, 0, 0.75);
font: ;
}

一直比较
比栈中所有的都大
那么栈中的所有奶牛没有机会
原因:一.比他靠前,二.比它大
发现栈中的一个比他大
也保留着
万一有奶牛比他小,那么就是他

使用方法二:

由于这道题目面需要知道某个奶牛仰慕的牛的序号,所以在栈里面不能仅仅存放牛的高度

以及

[NOIP2016]蚯蚓

这里面的问题,我经过归纳,有三种解决办法

  1. 制造一个结构体或者是pair对,直接存之
  2. 找依赖关系(可以拿一个经过题设条件推倒得到另一个),只记录一个源(就像是这道题目里面的,我可以只记录位置,通过奶牛高度数组来进行推倒)
  3. 全部经过特殊化,使得其具有一定的初始值,成为一种经过一个公式就可以推倒的内容(eg.[NOIP2016]蚯蚓)

代码

#include <iostream>
#include <stack>
using namespace std;
#define MAX 100007
int s[MAX];
int ans[MAX];
stack<int>st;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> s[i];
for (int i = n; i >= 1; i--)
{
while (!st.empty() && s[i] >= s[st.top()])
st.pop();
if (!st.empty())
{
ans[i] = st.top();
st.push(i);
}
else
{
ans[i] = 0;
st.push(i);
}
}
for (int i = 1; i <= n; i++)
{
cout << ans[i] << endl;
}
return 0;
}

[USACO 2009 Mar S]Look Up_via牛客网的更多相关文章

  1. NC24840 [USACO 2009 Mar S]Look Up

    NC24840 [USACO 2009 Mar S]Look Up 题目 题目描述 Farmer John's N (1 <= N <= 100,000) cows, convenient ...

  2. epoll内核源码详解(转 作者:赛罗·奥特曼 来源:牛客网)

    发现自己发的一篇面经后,很多小伙伴向我索要epoll的内核源码实现,那我就在牛客网发下这源码还有自己总结的流程. 另外 网上很多博客说epoll使用了共享内存,这个是完全错误的 ,可以阅读源码,会发现 ...

  3. 牛客网 --java问答题

    http://www.nowcoder.com/ 主要是自己什么都不怎么会.在这里可以学习很多的! 第一天看题自己回答,第二天看牛客网的答案! 1 什么是Java虚拟机?为什么Java被称作是“平台无 ...

  4. 牛客网《BAT面试算法精品课》学习笔记

    目录 牛客网<BAT面试算法精品课>学习笔记 牛客网<BAT面试算法精品课>笔记一:排序 牛客网<BAT面试算法精品课>笔记二:字符串 牛客网<BAT面试算法 ...

  5. C++版 - HDUoj 2010 3阶的水仙花数 - 牛客网

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C++版 - ...

  6. 牛客网第9场多校E(思维求期望)

    链接:https://www.nowcoder.com/acm/contest/147/E 来源:牛客网 题目描述 Niuniu likes to play OSU! We simplify the ...

  7. 牛客网暑期ACM多校训练营(第七场)Bit Compression

    链接:https://www.nowcoder.com/acm/contest/145/C 来源:牛客网 题目描述 A binary string s of length N = 2n is give ...

  8. Beautiful Numbers(牛客网)

    链接:https://ac.nowcoder.com/acm/problem/17385来源:牛客网 题目描述 NIBGNAUK is an odd boy and his taste is stra ...

  9. 牛客网华为机试题之Python解法

    牛客网华为机试题之Python解法 第1题 字符串最后一个单词的长度 a = input().split(" ") print(len(a[-1])) 第2题 计算字符个数 a = ...

随机推荐

  1. Spring Ioc源码分析系列--Ioc容器注册BeanPostProcessor后置处理器以及事件消息处理

    Spring Ioc源码分析系列--Ioc容器注册BeanPostProcessor后置处理器以及事件消息处理 前言 上一篇分析了BeanFactoryPostProcessor的作用,那么这一篇继续 ...

  2. 【多线程】线程优先级 Priority

    线程优先级 Priority Java提供一个线程调度器来监控程序中启动后进入就绪状态的所有线程,线程调度 器按照优先级决定应该调度哪个线程来执行. 线程的优先级用数字表示,范围从1~10. Thre ...

  3. C# settings 文件基础用法

    原文 自定义设置项类型 Serializable 修饰的枚举,可作为设置项类型 [Serializable] public enum DeviceBrand { None = 0, [Descript ...

  4. dpkg-DEB包管理器

    dpkg是Deb系列发行版操作系统下.deb软件包管理器. 语法 dpkg [option] [package] 选项 -i 安装Deb软件包. -r 删除Deb软件包. -P 删除Deb软件包的同时 ...

  5. 探究MySQL中SQL查询的成本

    成本 什么是成本,即SQL进行查询的花费的时间成本,包含IO成本和CPU成本. IO成本:即将数据页从硬盘中读取到内存中的读取时间成本.通常1页就是1.0的成本. CPU成本:即是读取和检测是否满足条 ...

  6. 基于C++11的数据库连接池实现

    0.注意 该篇文章为了让大家尽快看到效果,代码放置比较靠前,看代码前务必看下第4部分的基础知识. 1.数据库连接池 1.1 是什么? 数据库连接池负责分配.管理和释放数据库连接,属于池化机制的一种,类 ...

  7. Numpy的一些操作

    1.什么是Numpy 简单来说: Numpy(Numerical Python)是一个开源的Python科学计算库,用于快速处理任意维度的数组. Numpy支持常见的数组和矩阵操作.对于同样的数值计算 ...

  8. [第18届 科大讯飞杯 J] 能到达吗

    能到达吗 题目链接:牛客5278 J 能到达吗 Description 给定一个 \(n\times m\) 的地图,地图的左上角为 \((1, 1)\) ,右下角为 \((n,m)\). 地图上有 ...

  9. Python Beautiful Soup库

    Beautiful Soup库 Beautiful Soup库:https://www.crummy.com/software/BeautifulSoup/ 安装Beautiful Soup: 使用B ...

  10. Docker运行资源控制

    概述 ​ 一个 docker host 上会运行若干容器,每个容器都需要 CPU.内存和 IO 资源.对于 KVM,VMware 等虚拟化技术,用户可以控制分配多少 CPU.内存资源给每个虚拟机.对于 ...