链接:https://www.nowcoder.com/acm/contest/118/A
来源:牛客网
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
输入描述:
题目包含多组测试,请处理到文件结束;
第一行是一个整数n,代表地图的大小;
接下来的n行中,每行包含n个整数a,每个数字a代表当前位置敌人的数量;
1 < n <= 100,1 <= a <= 100,-1代表当前位置,-2代表安全区。
输出描述:
对于每组测试数据,请输出从当前位置到安全区所遇到最少的敌人数量,每个输出占一行。
输入例子:
5
6 6 0 -2 3
4 2 1 2 1
2 2 8 9 7
8 1 2 1 -1
9 7 2 1 2
输出例子:
9
-->
输入
5
6 6 0 -2 3
4 2 1 2 1
2 2 8 9 7
8 1 2 1 -1
9 7 2 1 2
输出
9
输入
5
62 33 18 -2 85
85 73 69 59 83
44 38 84 96 55
-1 11 90 34 50
19 73 45 53 95
输出
173
分析:spfa可以过,我用的优先队列,一条路走到黑,起点time不加,最后终点time + 2即可(因为BFS+ -2了,要还原)
/** :;LaEaHKEEGpPXU7;,
.:75pKH11252U252XapZgRQgD6XJscLr;,.
:LXpRgGaX521JLw1JswJJsJs22XHPPEZEGDOMMRDOa7.
.r2EDDZEpZPZP6KpHX5SXH5XXa5KwaXaSX5UJ1c77sLs2GMQQ6r .
,LpgOGpEZGZEZEpZKpHHU5wP5HEDgpXpHa2SSa5aSXULr7rrirrJXRBp; ;B
,J6MRZH6EgEEZE6E6EZZPZXXwSSGQXr::aPpP5USUHaHaKa5Lvrr7ri;rLHBB2: Kc
rpQDOpPPOGGZOGOZG6GEOEOEDPPGBa. .PaSSUXSUUUaUSaKXKS177r7rrrirSBBR7 .O,
:UBQOKPK6ZOOOEDEO6GZE6EpEpDgDBR: UBpXHa5aSaUS5SUS5XapPHJc7rrv7rr7sgBBs .g.
;gBMPXpO6GEOEOEOEGEOEE6EZEEDRGBB EB5pKSXpHKaHSX552S5aUHHEX17c7vr7777s5RBS: .R;
.sQBPXpDZOODOgODGOGgEDEOEOGgGgOOMB: LBKKSXSHa52aaKXHXKaa5aSaaHXSJLcL7vcc777JDBBg2;. Qi
;2ggp2EDDOggGEDGgDDOgGGZDOOZOGg6gEBX vBZaHUKaaUXXXSXXKXpXHXH5wwaa52U1wssLsLJccv1UDQBQ67. O7
:ZZUU5PROOEOZOZGGOODZOGgODZOOgOggRgRB; ;:..R6XaKKpP6PGppKPHpHpPX5aU21UUa5Sw52UwUJJv77L77sSpQMDU; ;B5
,SRJ7sSHGggEOZOEG6OODpOZgggOQQBBBBBQBBQ.,;;. LBOgOgDRDDZODMgQRgRDaa552a252UUa25w5UaU2sLvccs7r7sJZBBMr ,XQJ:
LQHr77J6RGOZDZOEGEDGgDRORQBBBQRDPU1Jscwa7.,::.:J7r;::::. ..,:;i7UOgRRRgDPH5SUSU52U2HHa1JJJLJLccLr71RBB, 7R2,
:RZv;77JSgGOZEODEDGOEggQBBBMS7;:,:,,.,.,.:7L;:,;.: ,: . ..... .:;rJU6GgGRggEZHPaKXX2S221Js1Lc7r:7QB. .XX:
7g1;;7rcXG6gpGDZGgZOOQBBQpr. ::::;:;:::Jr::sr;::;:.:vs,:::::::::::,, ,:7L5HGOggRgZUUU5wSUaJLc7r7BOiDr ...
.XX;;;irLHGKpZZZEKgDRBBB6i ,;;:;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. .....
JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... .
.Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr .......
1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:.......
D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ...
:Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. .......
sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. ..........
OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;..............
.BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,.............
1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... .............
..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... ..
,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........
.:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,.
.;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,.
,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. ..
rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2
;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr
r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77;
.:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc
.:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c
.:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw
;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2
J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU
JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J
U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1
2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ
a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U
5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5
U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2
s; ;::aBg, .; .Gv,H::,,::,;BQ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GpXsLLsJXHPOBBBc;vss5EMggZDODOgED6
LZJ::iwrrr72EPgXU5OBBBBBBBp7: .i5P6wL;, .:LS6DMgMgZKgEOPOGGDDGEXULvLSOBBBBBQBgDQDJ5rrr7JOQQDDZGEgDD
wp rR5, .HQRX7r72RQBBBBBQBMEK6Uc7sc7cHOU:, .:LHgOQg6ZOPZpZGGEDERZPwcr7LKDDaJr:. rBX;;:r:ir1DBQMgRgDp
7D,sw: , Z. .LgBBQBBOsJaQBBBBBBXrr. .:rwZBBQgROgDgDOERRMgROOScrLsPP5r, 7Qs,::::::rUgRgZOG6
,Q57:r ,: ,r U: .;; .vL7L;r:UG7.:sr;JSgQBgDEZXXUSXpHa21svr7r7s2v:. iQK...:,:::;LLJJws
OBHs;. :;;,v H: :6X; rpL;7pSrrr7r;::,....,,:;iirrvvvr, :BBPs;;:,,,,::;::
::rPDEL:..7:c;7r pK .: :KL.:r:.. ..:icsS5sr:,. JgGgBQDOSJss77r
:r;::: , PH r, ,;5: ,::::;7Ls7Lc7;: ,:7JP17rJUs
.:J: :; .,:K6BQS7:.,.,.
:r7Ji;r7;::;;.
. **/ #include <bits/stdc++.h>
using namespace std; #define FF(i, a, b) for(int i = a; i < b; i++)
#define RR(i, a, b) for(int i = a; i > b; i++)
#define ME(a, b) memset(a, b, sizeof(a))
#define SC(x) scanf("%d", &x)
#define PR(x) printf("%d\n", x)
#define INF 0x3f3f3f3f
#define MAX 330
#define MOD 1e9+7
#define E 2.71828182845
#define PI 3.14159265358979
#define M 8
#define N 8
typedef long long LL;
typedef pair<int, int> Author;
vector<pair<string, int> > VP; int matrix[MAX][MAX];
int dir[][] = {, , , , -, , , -};
int dis[MAX][MAX];
int n, q; struct Node{
int x, y, time;
bool operator < (const Node& a)const{return time > a.time;} //priority_queue
}bn, en, ln; bool check(int x, int y) {
if (x < || x >= n || y < || y >= n || dis[x][y])return ;
return ;
} int BFS(){
priority_queue<Node> p;ME(dis, );p.push(bn);
dis[bn.x][bn.y] = ;
while(!p.empty()){
ln = p.top(); p.pop();
if(ln.x == en.x && ln.y == en.y) return ln.time + ; //¼ôÖ¦
for(int i = ; i < ; i++){
Node cnt;
cnt.x = ln.x + dir[i][];
cnt.y = ln.y + dir[i][];
cnt.time = matrix[cnt.x][cnt.y] + ln.time;
if(check(cnt.x, cnt.y)){
dis[cnt.x][cnt.y] = ;
p.push(cnt);
}
}
}
return -;
} int main(void){
// #ifdef LOCAL
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// #endif
ios::sync_with_stdio(false); cin.tie();
int i, j, k, x1, y1, x2, y2; while(cin>>n){
for(i = ; i < n; i++)for(j = ; j < n; j++)cin>>matrix[i][j];
for(i = ; i < n; i++){
for(j = ; j < n; j++){
if(matrix[i][j] == -){bn.x = i; bn.y = j;bn.time = ;}
else if(matrix[i][j] == -){en.x = i; en.y = j;}
else ;
}
}
cout<<BFS()<<endl;
} return EXIT_SUCCESS;
}
链接:https://www.nowcoder.com/acm/contest/118/B
来源:牛客网
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
输入描述:
第一行是一个整数t,表示测试实例的个数;
然后是t行输入数据,每行包含两个正整数n和x,表示底数和保留位数。
(1 <= t <= 100,1 <= n <= 500,1 <= x <= 6)
输出描述:
对于每组输入数据,分别输出结果a,每个输出占一行。
输入例子:
3
1 3
7 6
9 1
输出例子:
1.000
451.807873
995.0
-->
输入
3
1 3
7 6
9 1
输出
1.000
451.807873
995.0
分析:这女的好可爱!!!,PI设置成acos(-1.0)即可
链接:https://www.nowcoder.com/acm/contest/118/C
来源:牛客网
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
输入描述:
八个整数:x
0
,y
0
,x
1
,y
1
,x
2
,y
2
,x
3
,y
3
。(0 < x
i
, y
i
< 100)
输出描述:
输出Yes如果可以调出, 否则输出No
输入例子:
2 3
1 1
3 3
2 4
输出例子:
Yes
-->
输入
2 3
1 1
3 3
2 4
输出
Yes
说明
一份颜料一, 一份颜料二, 一份颜料三混合即可。
备注:
输入数据有多组!
分析:23333,这题不会耶。
/** :;LaEaHKEEGpPXU7;,
.:75pKH11252U252XapZgRQgD6XJscLr;,.
:LXpRgGaX521JLw1JswJJsJs22XHPPEZEGDOMMRDOa7.
.r2EDDZEpZPZP6KpHX5SXH5XXa5KwaXaSX5UJ1c77sLs2GMQQ6r .
,LpgOGpEZGZEZEpZKpHHU5wP5HEDgpXpHa2SSa5aSXULr7rrirrJXRBp; ;B
,J6MRZH6EgEEZE6E6EZZPZXXwSSGQXr::aPpP5USUHaHaKa5Lvrr7ri;rLHBB2: Kc
rpQDOpPPOGGZOGOZG6GEOEOEDPPGBa. .PaSSUXSUUUaUSaKXKS177r7rrrirSBBR7 .O,
:UBQOKPK6ZOOOEDEO6GZE6EpEpDgDBR: UBpXHa5aSaUS5SUS5XapPHJc7rrv7rr7sgBBs .g.
;gBMPXpO6GEOEOEOEGEOEE6EZEEDRGBB EB5pKSXpHKaHSX552S5aUHHEX17c7vr7777s5RBS: .R;
.sQBPXpDZOODOgODGOGgEDEOEOGgGgOOMB: LBKKSXSHa52aaKXHXKaa5aSaaHXSJLcL7vcc777JDBBg2;. Qi
;2ggp2EDDOggGEDGgDDOgGGZDOOZOGg6gEBX vBZaHUKaaUXXXSXXKXpXHXH5wwaa52U1wssLsLJccv1UDQBQ67. O7
:ZZUU5PROOEOZOZGGOODZOGgODZOOgOggRgRB; ;:..R6XaKKpP6PGppKPHpHpPX5aU21UUa5Sw52UwUJJv77L77sSpQMDU; ;B5
,SRJ7sSHGggEOZOEG6OODpOZgggOQQBBBBBQBBQ.,;;. LBOgOgDRDDZODMgQRgRDaa552a252UUa25w5UaU2sLvccs7r7sJZBBMr ,XQJ:
LQHr77J6RGOZDZOEGEDGgDRORQBBBQRDPU1Jscwa7.,::.:J7r;::::. ..,:;i7UOgRRRgDPH5SUSU52U2HHa1JJJLJLccLr71RBB, 7R2,
:RZv;77JSgGOZEODEDGOEggQBBBMS7;:,:,,.,.,.:7L;:,;.: ,: . ..... .:;rJU6GgGRggEZHPaKXX2S221Js1Lc7r:7QB. .XX:
7g1;;7rcXG6gpGDZGgZOOQBBQpr. ::::;:;:::Jr::sr;::;:.:vs,:::::::::::,, ,:7L5HGOggRgZUUU5wSUaJLc7r7BOiDr ...
.XX;;;irLHGKpZZZEKgDRBBB6i ,;;:;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. .....
JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... .
.Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr .......
1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:.......
D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ...
:Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. .......
sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. ..........
OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;..............
.BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,.............
1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... .............
..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... ..
,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........
.:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,.
.;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,.
,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. ..
rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2
;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr
r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77;
.:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc
.:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c
.:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw
;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2
J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU
JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J
U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1
2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ
a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U
5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5
U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2
s; ;::aBg, .; .Gv,H::,,::,;BQDOGHPXpKBs .,. . .,. .r:;:6gOEBQRRRDggQgOHgMGL, .;PEHHXaaKaPXPKPaXS
s7.:,sBa :..S, vE::::; 7BBMgZH6pQBr . ,:, ,.,r2RHSSpMZPKRRZpgggav, ;UpEZaaaKHHUHPPaUJHGO
a;.775: .::rU. gR:,:. :;:BBBBQar . ,, ,.,7rggJwU6DDGMgOGgXc:, ,rPGOpKSXSXSKUKHU1UHgOEP
1i :SZJrLXpBBMRB: .v Ba,. :sv: . irsBUSpEEGPPpg65r:..,;sKZDZHSX5XaHU55K2wUGMRZ6Z6
:K :7asvwc2MgEQB, :gg.:iB7 .,,,:. ...,. . .. .:iM6GEpSSXZOEs:...;spZpKKXXSX5Xa5Ja5wwKGQDEpp6OZ
w; ,LXLr77sLwL5aR. gRgQgaQBi ,vJwvi,. .;;:;7: . . ,... rRDRJUSXpgas:,.:;U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DEL:..7:c;7r pK .: :KL.:r:.. ..:icsS5sr:,. JgGgBQDOSJss77r
:r;::: , PH r, ,;5: ,::::;7Ls7Lc7;: ,:7JP17rJUs
.:J: :; .,:K6BQS7:.,.,.
:r7Ji;r7;::;;.
. **/ #include <bits/stdc++.h>
using namespace std; #define FF(i, a, b) for(int i = a; i < b; i++)
#define RR(i, a, b) for(int i = a; i > b; i++)
#define ME(a, b) memset(a, b, sizeof(a))
#define SC(x) scanf("%d", &x)
#define PR(x) printf("%d\n", x)
#define INF 0x3f3f3f3f
#define MAX 550
#define MOD 1000000007
#define E 2.71828182845
#define PI 3.14159265358979
#define M 8
#define N 6
typedef long long LL;
typedef pair<int, int> Author;
vector<pair<string, int> > VP;
struct Point{
int x,y;
Point(){}
Point(int x,int y):x(x),y(y){}
int operator * (const Point&tmp)const{
return x*tmp.y-y*tmp.x;
}
Point operator - (const Point&tmp)const{
return Point(x-tmp.x,y-tmp.y);
}
}; bool solve(){ int x0,y0,x1,y1,x2,y2,x3,y3;
if(scanf("%d%d%d%d%d%d%d%d",&x0,&y0,&x1,&y1,&x2,&y2,&x3,&y3)==-) return ;
Point p[];
p[]=Point(x0,y0);
p[]=Point(x1,y1);
p[]=Point(x2,y2);
p[]=Point(x3,y3); int ans=abs((p[]-p[])*(p[]-p[]));
ans+=abs((p[]-p[])*(p[]-p[]));
ans+=abs((p[]-p[])*(p[]-p[]));
if(ans==abs((p[]-p[])*(p[]-p[]))) printf("Yes\n");
else printf("No\n"); return ;
} int main(){
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
while(solve()); return ;
}
链接:https://www.nowcoder.com/acm/contest/118/D
来源:牛客网
题目描述
输入描述:
第一个数是数字n(1<=n<=100), 代表输入的胜利者序列的规模, 接下来的n行描述了胜利者序列。第i行包含一个正整数a[i],(1<=a[i]<=3),代表着a[i]赢得比赛
输出描述:
输出YES如果胜利者序列合法, 否则NO
输入例子:
3
1
1
2
2
1
2
输出例子:
YES
NO
-->
输入
3
1
1
2
2
1
2
输出
YES
NO
说明
第一个例子中, 1赢了2, 3代替2; 1赢了3, 2代替3; 2赢了
第二个例子中, 1赢了2, 3代替2, 这时候2明显已经在场下了故不可能为胜利者
分析:弄个a,b,c交换就好了
/** :;LaEaHKEEGpPXU7;,
.:75pKH11252U252XapZgRQgD6XJscLr;,.
:LXpRgGaX521JLw1JswJJsJs22XHPPEZEGDOMMRDOa7.
.r2EDDZEpZPZP6KpHX5SXH5XXa5KwaXaSX5UJ1c77sLs2GMQQ6r .
,LpgOGpEZGZEZEpZKpHHU5wP5HEDgpXpHa2SSa5aSXULr7rrirrJXRBp; ;B
,J6MRZH6EgEEZE6E6EZZPZXXwSSGQXr::aPpP5USUHaHaKa5Lvrr7ri;rLHBB2: Kc
rpQDOpPPOGGZOGOZG6GEOEOEDPPGBa. .PaSSUXSUUUaUSaKXKS177r7rrrirSBBR7 .O,
:UBQOKPK6ZOOOEDEO6GZE6EpEpDgDBR: UBpXHa5aSaUS5SUS5XapPHJc7rrv7rr7sgBBs .g.
;gBMPXpO6GEOEOEOEGEOEE6EZEEDRGBB EB5pKSXpHKaHSX552S5aUHHEX17c7vr7777s5RBS: .R;
.sQBPXpDZOODOgODGOGgEDEOEOGgGgOOMB: LBKKSXSHa52aaKXHXKaa5aSaaHXSJLcL7vcc777JDBBg2;. Qi
;2ggp2EDDOggGEDGgDDOgGGZDOOZOGg6gEBX vBZaHUKaaUXXXSXXKXpXHXH5wwaa52U1wssLsLJccv1UDQBQ67. O7
:ZZUU5PROOEOZOZGGOODZOGgODZOOgOggRgRB; ;:..R6XaKKpP6PGppKPHpHpPX5aU21UUa5Sw52UwUJJv77L77sSpQMDU; ;B5
,SRJ7sSHGggEOZOEG6OODpOZgggOQQBBBBBQBBQ.,;;. LBOgOgDRDDZODMgQRgRDaa552a252UUa25w5UaU2sLvccs7r7sJZBBMr ,XQJ:
LQHr77J6RGOZDZOEGEDGgDRORQBBBQRDPU1Jscwa7.,::.:J7r;::::. ..,:;i7UOgRRRgDPH5SUSU52U2HHa1JJJLJLccLr71RBB, 7R2,
:RZv;77JSgGOZEODEDGOEggQBBBMS7;:,:,,.,.,.:7L;:,;.: ,: . ..... .:;rJU6GgGRggEZHPaKXX2S221Js1Lc7r:7QB. .XX:
7g1;;7rcXG6gpGDZGgZOOQBBQpr. ::::;:;:::Jr::sr;::;:.:vs,:::::::::::,, ,:7L5HGOggRgZUUU5wSUaJLc7r7BOiDr ...
.XX;;;irLHGKpZZZEKgDRBBB6i ,;;:;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. .....
JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... .
.Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr .......
1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:.......
D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ...
:Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. .......
sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. ..........
OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;..............
.BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,.............
1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... .............
..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... ..
,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........
.:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,.
.;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,.
,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. ..
rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2
;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr
r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77;
.:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc
.:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c
.:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw
;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2
J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU
JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J
U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1
2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ
a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U
5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5
U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2
s; ;::aBg, .; .Gv,H::,,::,;BQDOGHPXpKBs .,. . .,. .r:;:6gOEBQRRRDggQgOHgMGL, .;PEHHXaaKaPXPKPaXS
s7.:,sBa :..S, vE::::; 7BBMgZH6pQBr . ,:, ,.,r2RHSSpMZPKRRZpgggav, ;UpEZaaaKHHUHPPaUJHGO
a;.775: .::rU. gR:,:. :;:BBBBQar . ,, ,.,7rggJwU6DDGMgOGgXc:, ,rPGOpKSXSXSKUKHU1UHgOEP
1i :SZJrLXpBBMRB: .v Ba,. :sv: . irsBUSpEEGPPpg65r:..,;sKZDZHSX5XaHU55K2wUGMRZ6Z6
:K :7asvwc2MgEQB, :gg.:iB7 .,,,:. ...,. . .. .:iM6GEpSSXZOEs:...;spZpKKXXSX5Xa5Ja5wwK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:,:::;LLJJws
OBHs;. :;;,v H: :6X; rpL;7pSrrr7r;::,....,,:;iirrvvvr, :BBPs;;:,,,,::;::
::rPDEL:..7:c;7r pK .: :KL.:r:.. ..:icsS5sr:,. JgGgBQDOSJss77r
:r;::: , PH r, ,;5: ,::::;7Ls7Lc7;: ,:7JP17rJUs
.:J: :; .,:K6BQS7:.,.,.
:r7Ji;r7;::;;.
. **/ #include <bits/stdc++.h>
using namespace std; #define FF(i, a, b) for(int i = a; i < b; i++)
#define RR(i, a, b) for(int i = a; i > b; i++)
#define ME(a, b) memset(a, b, sizeof(a))
#define SC(x) scanf("%d", &x)
#define PR(x) printf("%d\n", x)
#define INF 0x3f3f3f3f
#define MAX 1001
#define MOD 1000000007
#define E 2.71828182845
#define PI 3.14159265358979
#define M 8
#define N 6
typedef long long LL;
typedef pair<int, int> Author;
vector<pair<string, int> > VP; int main(void){
// #ifdef LOCAL
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// #endif
ios::sync_with_stdio(false); cin.tie();
int n, i, a, b, c, win, flag; while(cin>>n){
a = ; b = ; c = ;flag = ;
for(i = ; i < n; i++){
cin>>win;
if(a != win && b != win)flag = ;
else if(a == win)swap(b, c);
else swap(a, c);
}
if(flag == ) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
} return EXIT_SUCCESS;
}
链接:https://www.nowcoder.com/acm/contest/118/E
来源:牛客网
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
Kirai每当看到很好玩的消息的时候总会回一串“2333...”。
Kirai其实十分高冷,他发现了这个问题。为了不希望别人立刻知道他在笑,他决定将两个“233..”乘在一起发出去。
输入描述:
输入样例有多组,全部是正整数。首先输入样例组数T(T≤1500)。
接下来输入T组数,每组数字由两个233串组成,每个233串长度3≤n≤50。
数据保证每个233串必然会有一个2作为开头,并且3的数量≥2。
输出描述:
两个233串的乘积。
输入例子:
2
233 233
23333333333333333333333333333333333333333333333333 23333333333333333333333333333333333333333333333333
输出例子:
54289
544444444444444444444444444444444444444444444444428888888888888888888888888888888888888888888888889
-->
输入
2
233 233
23333333333333333333333333333333333333333333333333 23333333333333333333333333333333333333333333333333
输出
54289
544444444444444444444444444444444444444444444444428888888888888888888888888888888888888888888888889
分析:大数相乘,板子题
C++:
#include <bits/stdc++.h>
using namespace std; #define FF(i, a, b) for(int i = a; i < b; i++)
#define RR(i, a, b) for(int i = a; i > b; i++)
#define ME(a, b) memset(a, b, sizeof(a))
#define SC(x) scanf("%d", &x)
#define PR(x) printf("%d\n", x)
#define MAX 1000
#define M 8
#define N 6
typedef long long LL;
typedef pair<int, int> Author; //±àÒëʱǶÈëµ÷Óô¦
inline int max(int a, int b){
return a > b ? a : b;
} inline int max(int a, int b, int c, int d){
return max(max(a, b), max(c, d));
} //bool cmp(const Node& a, const Node& b){
//
//}
char ch1[MAX];
char ch2[MAX];
int num1[MAX], num2[MAX], num3[ * MAX + ];
/*QAQ£º¿ªÊ¼Ñ§¼ÆË㼸ºÎºÍÊýѧºÍ´óÊýÎÊÌâ*/
int main(void){
int i, j, T, len1, len2, n; cin>>T;
while(T--){
//Êý¾ÝµÄ³õʼ»¯
cin>>ch1>>ch2;ME(num1, );ME(num2, ); ME(num3, );
len1 = strlen(ch1);
len2 = strlen(ch2); //µ¹Ðò´æ´¢
for(j = , i = len1 - ; i >= ; i--, j++)
num1[j] = ch1[i] - '';
for(j = , i = len2 - ; i >= ; i--, j++)
num2[j] = ch2[i] - ''; //´óÊýÏà³Ë
for(i = ; i < len1; i++)
for(j = ; j < len2; j++)
num3[i + j] += num1[i] * num2[j]; //½øλ
for(i = ; i < len1 + len2 - ; i++)
if(num3[i] >= ){
num3[i + ] += num3[i] / ;
num3[i] %= ;
} for(i = len1 + len2 - ; i >= ; i--)
if(num3[i] != )
break; for(; i >= ; i--)
cout<<num3[i];
cout<<endl; }
return ;
}
python3:
t = int(input())
while t > 0:
n,m = map(int,input().split())
print(n*m)
t-=1
链接:https://www.nowcoder.com/acm/contest/118/F
来源:牛客网
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
kirai获取了简化版扫雷(没有标记雷的小旗)的后台数据(后台数据包括所有数字和雷的位置),转换为一个n*m(1≤n, m≤500)的矩阵并对格子类型做了如下标记:
雷被标记为'*';
点开的空白区域标记为'0';
未点开的空白区域标记为'.';
数字1~8代表周围有多少雷;
kirai非常笨,他希望你帮他完成这样的任务:
给定k(1≤k≤min(可扫位置数, 10))个位置坐标和扫雷游戏的后台数据,输出点开指定位置序列后游戏的结果,初始时游戏中没有点开任何位置。
注:数据保证扫雷过程中不会重复点击已扫位置。
输入描述:
输入样例有多组,全部是正整数。首先输入样例组数T(T≤10)。
接下来输入T组数,每组数据第一行包括四个正整数n,m,k(1≤n, m≤500, 1≤k≤min(可扫位置数, 10))分别表示地图的行、列数和即将点开的位置数。紧接着是一个n*m的矩阵,代表扫雷的后台数据,。
矩阵后是k个整数对x
i
, y
i
(1≤i≤k, 1≤x
i
≤n, 1≤y
i
≤m),表示依次点开的位置。
输出描述:
如果某一步踩到雷,输出"Game over in step x"(不包括引号",表示第x步踩中雷);未踩到雷则根据扫雷的游戏规则更新,并输出最后一步结束后显示给kirai的矩阵。
输入例子:
1
5 5 3
2*11*
*2111
22...
*1...
11...
1 1
3 3
1 2
输出例子:
Game over in step 3
-->
输入
1
5 5 3
2*11*
*2111
22...
*1...
11...
1 1
3 3
1 2
输出
Game over in step 3
说明
2....
.....
.....
.....
.....
2....
.2111
.2000
.1000
.1000
Game over in step 3
分析:模拟下就好,数字就是单个标记,炸弹可以直接标记退出,空白地方要DFS全部标记,然后总的循环把周围8个方向标记,最后输入标记的点,没标记的输入‘.’,这里DFS范围弄错了,尴尬,这次比赛被板子卡了好久
/** :;LaEaHKEEGpPXU7;,
.:75pKH11252U252XapZgRQgD6XJscLr;,.
:LXpRgGaX521JLw1JswJJsJs22XHPPEZEGDOMMRDOa7.
.r2EDDZEpZPZP6KpHX5SXH5XXa5KwaXaSX5UJ1c77sLs2G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;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. .....
JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... .
.Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr .......
1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:.......
D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ...
:Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. .......
sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. ..........
OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;..............
.BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,.............
1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... .............
..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... ..
,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........
.:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,.
.;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,.
,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. ..
rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2
;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr
r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77;
.:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc
.:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c
.:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw
;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2
J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU
JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J
U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1
2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ
a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U
5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5
U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2
s; ;::aBg, .; .Gv,H::,,::,;BQDOGHPXpKBs .,. . .,. .r:;:6gOEBQRRRDggQgOHgMGL, .;PEHHXaaKaPXPKPaXS
s7.:,sBa :..S, vE::::; 7BBMgZH6pQBr . ,:, ,.,r2RHSSpMZPKRRZpgggav, ;UpEZaaaKHHUHPPaUJHGO
a;.775: .::rU. gR:,:. :;:BBBBQar . ,, ,.,7rggJwU6DDGMgOGgXc:, ,rPGOpKSXSXSKUKHU1UHgOEP
1i :SZJrLXpBBMRB: .v Ba,. :sv: . irsBUSpEEGPPpg65r:..,;sKZDZHSX5XaHU55K2wUGMRZ6Z6
:K :7asvwc2MgEQB, :gg.:iB7 .,,,:. ...,. . .. .:iM6GEpSSXZOEs:...;spZpKKXXSX5Xa5Ja5wwKGQDEpp6OZ
w; ,LXLr77sLwL5aR. gRgQgaQBi ,vJwvi,. .;;:;7: . . ,... rRDRJUSXpgas:,.:;U66SaHa2X5aUa552X12SgQgpZpEpGOD
H: ;XJ;77rv7rJUaQ;rgaPgXXHBB; . . .ri:;; ,: . :6QZEKHXpXXL:,::r1PKXaa2XSS5a5S5UJ22aOBgEpOppZOOgG
iwsJsr7rsLrrLcJ2gQGXHwa1SUHBB: . ... . .., : 1BRKpOEGp2Jr;::rsXP1Uaa2U5a5aUa5SsSpgQRZGZEEZZOOgDg
,cs5aXaP552ssLwRSHXaSS5asXBB. . . . LBBgGgZHsr;vrr;rcXpP5UUS5X5S2XS5SS1URBggpEZgDDGOGggRD
,;irrs2KgQRPJJJSUXKXSHJpBM . . . ZBBOUsr;:. ,,,rHgZPUaSaUSUSSXaUPXsSBB6ZZp6EEGOOGDEggO
;BBQQZaSJ5J15SJDQ7 .iEBL:. . .,:,:;SRQGZXPXXSHaS2UUSUSswQB6OZgG6pZZGODEOGDE
JgUri1aGEpEpXSS5LBQ, .rLap2Jr ;712OO6ZggRDZXHXpKK2211LLLc7wgBa2PODRGE6OZgDgGDGD
7QB; ,Jc76DaZXOZgDPEBBX, :c1HEZ1c;:,.,:;cHDgQQggMZgGOZO6OEGpXsLLsJXHPOBBBc;vss5EMggZDODOgED6
LZJ::iwrrr72EPgXU5OBBBBBBBp7: .i5P6wL;, .:LS6DMgMgZKgEOPOGGDDGEXULvLSOBBBBBQBgDQDJ5rrr7JOQQDDZGEgDD
wp rR5, .HQRX7r72RQBBBBBQBMEK6Uc7sc7cHOU:, .:LHgOQg6ZOPZpZGGEDERZPwcr7LKDDaJr:. rBX;;:r:ir1DBQMgRgDp
7D,sw: , Z. .LgBBQBBOsJaQBBBBBBXrr. .:rwZBBQgROgDgDOERRMgROOScrLsPP5r, 7Qs,::::::rUgRgZOG6
,Q57:r ,: ,r U: .;; .vL7L;r:UG7.:sr;JSgQBgDEZXXUSXpHa21svr7r7s2v:. iQK...:,:::;LLJJws
OBHs;. :;;,v H: :6X; rpL;7pSrrr7r;::,....,,:;iirrvvvr, :BBPs;;:,,,,::;::
::rPDEL:..7:c;7r pK .: :KL.:r:.. ..:icsS5sr:,. JgGgBQDOSJss77r
:r;::: , PH r, ,;5: ,::::;7Ls7Lc7;: ,:7JP17rJUs
.:J: :; .,:K6BQS7:.,.,.
:r7Ji;r7;::;;.
. **/ #include <bits/stdc++.h>
using namespace std; #define FF(i, a, b) for(int i = a; i < b; i++)
#define RR(i, a, b) for(int i = a; i > b; i++)
#define ME(a, b) memset(a, b, sizeof(a))
#define SC(x) scanf("%d", &x)
#define PR(x) printf("%d\n", x)
#define INF 0x3f3f3f3f
#define MAX 550
#define MOD 1000000007
#define E 2.71828182845
#define PI 3.14159265358979
#define M 8
#define N 6
typedef long long LL;
typedef pair<int, int> Author;
vector<pair<string, int> > VP; int n, m;
int dis[MAX][MAX];
int dir[][] = {, , , , -, , , -};
char matrix[MAX][MAX];
char mymatrix[MAX][MAX]; int DFS(int x, int y){
if(x < || x > n || y < || y > m || matrix[x][y] != '.' || dis[x][y] == ) return ;
dis[x][y] = ;
DFS(x + , y); DFS(x - , y); DFS(x, y + ); DFS(x, y - );
return ;
} int main(void){
ios::sync_with_stdio(false); cin.tie();
int i, j, T, k, ix, iy, flag, index; cin>>T;
while(T--){
cin>>n>>m>>k; ME(dis, );flag = ; index = ;
for(i = ; i <= n; i++)for(j = ; j <= m; j++)cin>>matrix[i][j];
for(i = ; i <= n; i++)for(j = ; j <= m; j++)mymatrix[i][j] = '.';
for(i = ; i <= k; i++){
cin>>ix>>iy;
if(matrix[ix][iy] == '*' && flag == ){flag = ;index = i;}
else if(matrix[ix][iy] == '.')DFS(ix, iy);
else dis[ix][iy] = ;
}
for(int x = ; x <= n; x++)for(int y = ; y <= m; y++)if(matrix[x][y] == '.' && dis[x][y] == )dis[x - ][y - ] = dis[x - ][y] = dis[x - ][y + ] = dis[x][y - ] = dis[x][y + ] = dis[x + ][y - ] = dis[x + ][y] = dis[x + ][y + ] = ;
if(flag == )cout<<"Game over in step "<<index<<endl;
else{
for(i = ; i <= n; i++){
for(j = ; j <= m; j++){
if(dis[i][j] == && matrix[i][j] != '.')cout<<matrix[i][j];
else if(dis[i][j] == && matrix[i][j] == '.') cout<<"";
else cout<<mymatrix[i][j];
}
cout<<endl;
}
}
} return EXIT_SUCCESS;
}
链接:https://www.nowcoder.com/acm/contest/118/G
来源:牛客网
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
被过道分成了两半。当A和B到了车上时,一些位子已经有人了。
A和B是好基友,于是他们想要找一对连在一起的座位。两个连在一起的座位是同一排但是不被过道隔开的两个座位。给定一列火车上的座位情况,请你寻找一下能否找到一对连座?
输入描述:
每组样例第一行为一个整数n,1<=n<=1000,表示火车一共有n排座位。
之后的n行每行为一个含有五个字符的字符串,第i个字符串的五个字符表示第i排座位的情况。每一个字符串的第三个字符都为字符‘|’,表示过道,其余每个字符表示一个座位的占用情况。字符'O'表示座位为空,字符'X'表示座位上已经有人,即被占用。
输出描述:
如果能够找到一组连座,则先输出一行字符串“YES”(不要输出引号)在第一行,在接下来的n
行输出车的座位情况,除了A和B的座位用字符'+'表示,其余输出格式与输入格式中车的座位情况一致。
如果不能够找到一组连座,仅输出一行“NO”(不要输出引号)即可。
有多组座位安排方式时,将A和B安排在前面的排,如果同一排还有两组可行解,选择将A和B排在左边。
例如一组车的情况为这样的时候,应该将其安排为箭头右边的情况。
OO|OO --> ++|OO
OO|OO --> OO|OO
输入例子:
6
OO|OX
XO|XX
OX|OO
XX|OX
OO|OO
OO|XX
4
XO|OX
XO|XX
OX|OX
XX|OX
5
XX|XX
XX|XX
XO|OX
XO|OO
OX|XO
输出例子:
YES
++|OX
XO|XX
OX|OO
XX|OX
OO|OO
OO|XX
NO
YES
XX|XX
XX|XX
XO|OX
XO|++
OX|XO
-->
输入
6
OO|OX
XO|XX
OX|OO
XX|OX
OO|OO
OO|XX
4
XO|OX
XO|XX
OX|OX
XX|OX
5
XX|XX
XX|XX
XO|OX
XO|OO
OX|XO
输出
YES
++|OX
XO|XX
OX|OO
XX|OX
OO|OO
OO|XX
NO
YES
XX|XX
XX|XX
XO|OX
XO|++
OX|XO
说明
注意
第一组样例中,下面的安排是不合法的。
O+|+X
XO|XX
OX|OO
XX|OX
OO|OO
OO|XX
分析:水题,但是这妹子很好看、QAQ
/** :;LaEaHKEEGpPXU7;,
.:75pKH11252U252XapZgRQgD6XJscLr;,.
:LXpRgGa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:.:vs,:::::::::::,, ,:7L5HGOggRgZUUU5wSUaJLc7r7BOiDr ...
.XX;;;irLHGKpZZZEKgDRBBB6i ,;;:;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. .....
JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... .
.Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr .......
1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:.......
D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ...
:Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. .......
sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. ..........
OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;..............
.BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,.............
1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... .............
..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... ..
,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........
.:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,.
.;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,.
,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. ..
rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2
;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr
r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77;
.:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc
.:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c
.:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw
;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2
J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU
JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J
U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1
2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ
a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U
5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5
U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2
s; ;::aBg, .; .Gv,H::,,::,;BQDOGHPXpKBs .,. . .,. .r:;:6gOEBQRRRDggQgOHgMGL, .;PEHHXaaKaPXPKPaXS
s7.:,sBa :..S, vE::::; 7BBMgZH6pQBr . ,:, ,.,r2RHSSpMZPKRRZpgggav, ;UpEZaaaKHHUHPPaUJHGO
a;.775: .::rU. gR:,:. :;:BBBBQar . ,, ,.,7rggJwU6DDGMgOGgXc:, ,rPGOpKSXSXSKUKHU1UHgOEP
1i :SZJrLXpBBMRB: .v Ba,. :sv: . irsBUSpEEGPPpg65r:..,;sKZDZHSX5XaHU55K2wUGMRZ6Z6
:K :7asvwc2MgEQB, :gg.:iB7 .,,,:. ...,. . .. .:iM6GEpSSXZOEs:...;spZpKKXXSX5Xa5Ja5wwKGQDEpp6OZ
w; ,LXLr77sLwL5aR. gRgQgaQBi ,vJwvi,. .;;:;7: . . ,... rRDRJUSXpgas:,.:;U66SaHa2X5aUa552X12SgQgpZpEpGOD
H: ;XJ;77rv7rJUaQ;rgaPgXXHBB; . . .ri:;; ,: . :6QZEKHXpXXL:,::r1PKXaa2XSS5a5S5UJ22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BQS7:.,.,.
:r7Ji;r7;::;;.
. **/ #include <bits/stdc++.h>
using namespace std; #define FF(i, a, b) for(int i = a; i < b; i++)
#define RR(i, a, b) for(int i = a; i > b; i++)
#define ME(a, b) memset(a, b, sizeof(a))
#define SC(x) scanf("%d", &x)
#define PR(x) printf("%d\n", x)
#define INF 0x3f3f3f3f
#define MAX 1001
#define MOD 1000000007
#define E 2.71828182845
#define PI 3.14159265358979
#define M 8
#define N 6
typedef long long LL;
typedef pair<int, int> Author;
vector<pair<string, int> > VP; char seat[MAX][];
int main(void){
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
ios::sync_with_stdio(false); cin.tie();
int i, j, n, flag; while(cin>>n){
flag = ;
for(i = ; i < n; i++){
cin>>seat[i];
for(j = ; j < ; j++){
if(seat[i][j] == 'O' && seat[i][j + ] == 'O' && flag){
flag = ;
seat[i][j] = '+'; seat[i][j + ] = '+';
}
}
}
if(!flag){
cout<<"YES"<<endl;
for(i = ; i < n; i++){
for(j = ; j < ; j++)cout<<seat[i][j];
cout<<endl;
}
}
else cout<<"NO"<<endl;
} return EXIT_SUCCESS;
}
链接:https://www.nowcoder.com/acm/contest/118/H
来源:牛客网
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
输入描述:
每组样例第一行为一个整数n,1<=n<=100,第二行为n项的01序列,每一项之间用一个空格隔开。
输出描述:
输出一个正整数,表示最多能展示的项目个数。
输入例子:
4
1 1 0 1
6
0 1 0 0 1 0
1
0
输出例子:
3
4
1
-->
输入
4
1 1 0 1
6
0 1 0 0 1 0
1
0
输出
3
4
1
分析:求最长不降子序列,暴力应该也可以过,水题,总共才100个长度,二分或者直接upper_bound就可以了,如果求最长不升子序列,就把if换一下,upper_bound换成lower_bound即可
/** :;LaEaHKEEGpPXU7;,
.:75pKH11252U252XapZgRQgD6XJscLr;,.
:LXpRgGaX521JLw1JswJJsJs22XHPPEZEGDOMMRDOa7.
.r2EDDZEpZPZ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r ...
.XX;;;irLHGKpZZZEKgDRBBB6i ,;;:;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. .....
JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... .
.Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr .......
1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:.......
D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ...
:Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. .......
sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. ..........
OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;..............
.BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,.............
1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... .............
..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... ..
,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........
.:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,.
.;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,.
,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. ..
rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2
;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr
r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77;
.:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc
.:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c
.:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw
;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2
J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU
JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J
U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1
2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ
a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U
5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5
U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2
s; ;::aBg, .; .Gv,H::,,::,;BQDOGHPXpKBs .,. . .,. .r:;:6gOEBQRRRDggQgOHgMGL, .;PEHHXaaKaPXPKPaXS
s7.:,sBa :..S, vE::::; 7BBMgZH6pQBr . ,:, ,.,r2RHSSpMZPKRRZpgggav, ;UpEZaaaKHHUHPPaUJHGO
a;.775: .::rU. gR:,:. :;:BBBBQar . ,, ,.,7rggJwU6DDGMgOGgXc:, ,rPGOpKSXSXSKUKHU1UHgOEP
1i :SZJrLXpBBMRB: .v Ba,. :sv: . irsBUSpEEGPPpg65r:..,;sKZDZHSX5XaHU55K2wUGMRZ6Z6
:K :7asvwc2MgEQB, :gg.:iB7 .,,,:. ...,. . .. .:iM6GEpSSXZOEs:...;spZpKKXXSX5Xa5Ja5wwKGQDEpp6OZ
w; ,LXLr77sLwL5aR. gRgQgaQBi ,vJwvi,. .;;:;7: . . ,... rRDRJUSXpgas:,.:;U66SaHa2X5aUa552X12SgQgpZpEpGOD
H: ;XJ;77rv7rJUaQ;rgaPgXXHBB; . . .ri:;; ,: . :6QZEKHXpXXL:,::r1PKXaa2XSS5a5S5UJ22aOBgEpOppZOOgG
iwsJsr7rsLrrLcJ2gQGXHwa1SUHBB: . ... . .., : 1BRKpOEGp2Jr;::rsXP1Uaa2U5a5aUa5SsSpgQRZGZEEZZOOgDg
,cs5aXaP552ssLwRSHXaSS5asXBB. . . . LBBgGgZHsr;vrr;rcXpP5UUS5X5S2XS5SS1URBggpEZgDDGOGggRD
,;irrs2KgQRPJJJSUXKXSHJpBM . . . ZBBOUsr;:. ,,,rHgZPUaSaUSUSSXaUPXsSBB6ZZp6EEGOOGDEggO
;BBQQZaSJ5J15SJDQ7 .iEBL:. . .,:,:;SRQGZXPXXSHaS2UUSUSswQB6OZgG6pZZGODEOGDE
JgUri1aGEpEpXSS5LBQ, .rLap2Jr ;712OO6ZggRDZXHXpKK2211LLLc7wgBa2PODRGE6OZgDgGDGD
7QB; ,Jc76DaZXOZgDPEBBX, :c1HEZ1c;:,.,:;cHDgQQggMZgGOZO6OEGpXsLLsJXHPOBBBc;vss5EMggZDODOgED6
LZJ::iwrrr72EPgXU5OBBBBBBBp7: .i5P6wL;, .:LS6DMgMgZKgEOPOGGDDGEXULvLSOBBBBBQBgDQDJ5rrr7JOQQDDZGEgDD
wp rR5, .HQRX7r72RQBBBBBQBMEK6Uc7sc7cHOU:, .:LHgOQg6ZOPZpZGGEDERZPwcr7LKDDaJr:. rBX;;:r:ir1DBQMgRgDp
7D,sw: , Z. .LgBBQBBOsJaQBBBBBBXrr. .:rwZBBQgROgDgDOERRMgROOScrLsPP5r, 7Qs,::::::rUgRgZOG6
,Q57:r ,: ,r U: .;; .vL7L;r:UG7.:sr;JSgQBgDEZXXUSXpHa21svr7r7s2v:. iQK...:,:::;LLJJws
OBHs;. :;;,v H: :6X; rpL;7pSrrr7r;::,....,,:;iirrvvvr, :BBPs;;:,,,,::;::
::rPDEL:..7:c;7r pK .: :KL.:r:.. ..:icsS5sr:,. JgGgBQDOSJss77r
:r;::: , PH r, ,;5: ,::::;7Ls7Lc7;: ,:7JP17rJUs
.:J: :; .,:K6BQS7:.,.,.
:r7Ji;r7;::;;.
. **/ #include <bits/stdc++.h>
using namespace std; #define FF(i, a, b) for(int i = a; i < b; i++)
#define RR(i, a, b) for(int i = a; i > b; i++)
#define ME(a, b) memset(a, b, sizeof(a))
#define SC(x) scanf("%d", &x)
#define PR(x) printf("%d\n", x)
#define INF 0x3f3f3f3f
#define MAX 110
#define MOD 1000000007
#define E 2.71828182845
#define PI 3.14159265358979
#define M 8
#define N 6
typedef long long LL;
typedef pair<int, int> Author;
vector<pair<string, int> > VP; int main(void){
// #ifdef LOCAL
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
// #endif
// ios::sync_with_stdio(false); cin.tie(0); int i, j, a[MAX], b[MAX], n, len; while(cin>>n){
for(i = ; i <= n; i++) cin>>a[i];ME(b, );
len = ; b[] = a[];
for(i = ; i <= n; i++){
if(a[i] >= b[len]) b[++len] = a[i];
else{
j = upper_bound(b + , b + len + , a[i]) - b;
b[j] = a[i];
}
}
cout<<len<<endl; } return EXIT_SUCCESS;
}
链接:https://www.nowcoder.com/acm/contest/118/I
来源:牛客网
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
为了更快达到目的地,萌新计算了经费后为大家租赁了一辆限乘k人的车,队员们都非常不满,但对于萌新队长敢怒不敢言。
现已知队员走路的速度为v1,车的速度为v2,每位队员只能上车一次。
你的任务是帮助萌新确定到达目的地所用的时间(保留10位小数,考虑上车下车、车掉头时间不计)
输入描述:
第一行输入一个整数m,代表m组数据。
接下来m行,输入5个正整数n,l,v
1
,v
2
,k。
其中1≤m≤1000,1≤n≤10000, 1≤l≤10
9
, 1≤v
1
<v
2
≤10
9
, 1≤k≤n
输出描述:
输出一行,为一个实数。代表萌新确定到达目的地所用的时间(保留10位小数,考虑上车下车、车掉头时间不计)
输入例子:
1
3 6 1 2 1
输出例子:
4.7142857143
-->
输入
1
3 6 1 2 1
输出
4.7142857143
分析:小学生数学题 http://www.1010jiajiao.com/xxsx/shiti_id_730fe4de7fddc8a4573057ef03462705
真刺激啊,我可能要重读幼儿园了!!就是要分段,车要保持最短时间,就要在半路上停车,下人,回去再接人,最后都能一起到终点
/** :;LaEaHKEEGpPXU7;,
.:75pKH11252U252XapZgRQgD6XJscLr;,.
:LXpRgGaX521JLw1JswJJsJs22XHPPEZEGDOMMRDOa7.
.r2EDDZEpZPZP6KpHX5SXH5XXa5KwaXaSX5UJ1c77sLs2GMQQ6r .
,LpgOGpEZGZEZEpZKpHHU5wP5HEDgpXpHa2SSa5aSXULr7rrirrJXRBp; ;B
,J6MRZH6EgEEZE6E6EZZPZXXwSSGQXr::aPpP5USUHaHaKa5Lvrr7ri;rLHBB2: Kc
rpQDOpPPOGGZOGOZG6GEOEOEDPPGBa. .PaSSUXSUUUaUSaKXKS177r7rrrirSBBR7 .O,
:UBQOKPK6ZOOOEDEO6GZE6EpEpDgDBR: UBpXHa5aSaUS5SUS5XapPHJc7rrv7rr7sgBBs .g.
;gBMPXpO6GEOEOEOEGEOEE6EZEEDRGBB EB5pKSXpHKaHSX552S5aUHHEX17c7vr7777s5RBS: .R;
.sQBPXpDZOODOgODGOGgEDEOEOGgGgOOMB: LBKKSXSHa52aaKXHXKaa5aSaaHXSJLcL7vcc777JDBBg2;. Qi
;2ggp2EDDOggGEDGgDDOgGGZDOOZOGg6gEBX vBZaHUKaaUXXXSXXKXpXHXH5wwaa52U1wssLsLJccv1UDQBQ67. O7
:ZZUU5PROOEOZOZGGOODZOGgODZOOgOggRgRB; ;:..R6XaKKpP6PGppKPHpHpPX5aU21UUa5Sw52UwUJJv77L77sSpQMDU; ;B5
,SRJ7sSHGggEOZOEG6OODpOZgggOQQBBBBBQBBQ.,;;. LBOgOgDRDDZODMgQRgRDaa552a252UUa25w5UaU2sLvccs7r7sJZBBMr ,XQJ:
LQHr77J6RGOZDZOEGEDGgDRORQBBBQRDPU1Jscwa7.,::.:J7r;::::. ..,:;i7UOgRRRgDPH5SUSU52U2HHa1JJJLJLccLr71RBB, 7R2,
:RZv;77JSgGOZEODEDGOEggQBBBMS7;:,:,,.,.,.:7L;:,;.: ,: . ..... .:;rJU6GgGRggEZHPaKXX2S221Js1Lc7r:7QB. .XX:
7g1;;7rcXG6gpGDZGgZOOQBBQpr. ::::;:;:::Jr::sr;::;:.:vs,:::::::::::,, ,:7L5HGOggRgZUUU5wSUaJLc7r7BOiDr ...
.XX;;;irLHGKpZZZEKgDRBBB6i ,;;:;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. .....
JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... .
.Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr .......
1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:.......
D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ...
:Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. .......
sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. ..........
OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;..............
.BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,.............
1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... .............
..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... ..
,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........
.:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,.
.;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,.
,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. ..
rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2
;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr
r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77;
.:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc
.:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c
.:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw
;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2
J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU
JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J
U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1
2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ
a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U
5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5
U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2
s; ;::aBg, .; .Gv,H::,,::,;BQDOGHPXpKBs .,. . .,. .r:;:6gOEBQRRRDggQgOHgMGL, .;PEHHXaaKaPXPKPaXS
s7.:,sBa :..S, vE::::; 7BBMgZH6pQBr . ,:, ,.,r2RHSSpMZPKRRZpgggav, ;UpEZaaaKHHUHPPaUJHGO
a;.775: .::rU. gR:,:. :;:BBBBQar . ,, ,.,7rggJwU6DDGMgOGgXc:, ,rPGOpKSXSXSKUKHU1UHgOEP
1i :SZJrLXpBBMRB: .v Ba,. :sv: . irsBUSpEEGPPpg65r:..,;sKZDZHSX5XaHU55K2wUGMRZ6Z6
:K :7asvwc2MgEQB, :gg.:iB7 .,,,:. ...,. . .. .:iM6GEpSSXZOEs:...;spZpKKXXSX5Xa5Ja5wwKGQDEpp6OZ
w; ,LXLr77sLwL5aR. gRgQgaQBi ,vJwvi,. .;;:;7: . . ,... rRDRJUSXpgas:,.:;U66SaHa2X5aUa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pK .: :KL.:r:.. ..:icsS5sr:,. JgGgBQDOSJss77r
:r;::: , PH r, ,;5: ,::::;7Ls7Lc7;: ,:7JP17rJUs
.:J: :; .,:K6BQS7:.,.,.
:r7Ji;r7;::;;.
. **/ #include <bits/stdc++.h>
using namespace std; #define FF(i, a, b) for(int i = a; i < b; i++)
#define RR(i, a, b) for(int i = a; i > b; i++)
#define ME(a, b) memset(a, b, sizeof(a))
#define SC(x) scanf("%d", &x)
#define PR(x) printf("%d\n", x)
#define INF 0x3f3f3f3f
#define MAX 1001
#define MOD 1000000007
#define E 2.71828182845
#define PI 3.14159265358979
#define M 8
#define N 6
typedef long long LL;
typedef pair<int, int> Author;
vector<pair<string, int> > VP; int main(void){
int T; cin>>T;
while(T--){
double n,s,vr,vc,k;
int a,b,c,d,e;
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
n=a,s=b,vr=c,vc=d,k=e;
int p=(n+k-)/k;
printf("%.10lf\n",vr<vc?(p+(p-)*(vc-vr)/(vc+vr))*s/(vr*(p+(p-)*(vc-vr)/(vc+vr)-)+vc):s/vr);
} return EXIT_SUCCESS;
}
链接:https://www.nowcoder.com/acm/contest/118/J
来源:牛客网
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
现已知船相对于水的速度为v1,水流的速度为v2。
由于萌新想到达起点的正对岸,所以他会一直调整船行驶的方向朝向正对岸。
输入描述:
第一行输入一个整数n,表示测试用例数;
接下来n行,每行输入三个整数s、v
1
、v
2
。
其中,1≤n≤1000,0≤s≤100, 0≤v
1
,v
2
≤100。
输出描述:
输出一个实数,你的任务是计算萌新将用多少时间度过这条河(保留10位小数);若他不能到达起点的正对岸,输出“Infinity”。
输入例子:
3
2 2 2
2 4 3
5 6 5
输出例子:
Infinity
1.1428571429
2.7272727273
-->
输入
3
2 2 2
2 4 3
5 6 5
输出
Infinity
1.1428571429
2.7272727273
分析:HDU5761:http://acm.hdu.edu.cn/showproblem.php?pid=5761,数学积分求解,这题意是它船要到正对岸(竖线)且船头要'
也要是竖线,所以要不断调整方向
/** :;LaEaHKEEGpPXU7;,
.:75pKH11252U252XapZgRQgD6XJscLr;,.
:LXpRgGaX521JLw1JswJJsJs22XHPPEZEGDOMMRDOa7.
.r2EDDZEpZPZP6KpHX5SXH5XXa5KwaXaSX5UJ1c77sLs2GMQQ6r .
,LpgOGpEZGZEZEpZKpHHU5wP5HEDgpXpHa2SSa5aSXULr7rrirrJXRBp; ;B
,J6MRZH6EgEEZE6E6EZZPZXXwSSGQXr::aPpP5USUHaHaKa5Lvrr7ri;rLHBB2: Kc
rpQDOpPPOGGZOGOZG6GEOEOEDPPGBa. .PaSSUXSUUUaUSaKXKS177r7rrrirSBBR7 .O,
:UBQOKPK6ZOOOEDEO6GZE6EpEpDgDBR: UBpXHa5aSaUS5SUS5XapPHJc7rrv7rr7sgBBs .g.
;gBMPXpO6GEOEOEOEGEOEE6EZEEDRGBB EB5pKSXpHKaHSX552S5aUHHEX17c7vr7777s5RBS: .R;
.sQBPXpDZOODOgODGOGgEDEOEOGgGgOOMB: LBKKSXSHa52aaKXHXKaa5aSaaHXSJLcL7vcc777JDBBg2;. Qi
;2ggp2EDDOggGEDGgDDOgGGZDOOZOGg6gEBX vBZaHUKaaUXXXSXXKXpXHXH5wwaa52U1wssLsLJccv1UDQBQ67. O7
:ZZUU5PROOEOZOZGGOODZOGgODZOOgOggRgRB; ;:..R6XaKKpP6PGppKPHpHpPX5aU21UUa5Sw52UwUJJv77L77sSpQMDU; ;B5
,SRJ7sSHGggEOZOEG6OODpOZgggOQQBBBBBQBBQ.,;;. LBOgOgDRDDZODMgQRgRDaa552a252UUa25w5UaU2sLvccs7r7sJZBBMr ,XQJ:
LQHr77J6RGOZDZOEGEDGgDRORQBBBQRDPU1Jscwa7.,::.:J7r;::::. ..,:;i7UOgRRRgDPH5SUSU52U2HHa1JJJLJLccLr71RBB, 7R2,
:RZv;77JSgGOZEODEDGOEggQBBBMS7;:,:,,.,.,.:7L;:,;.: ,: . ..... .:;rJU6GgGRggEZHPaKXX2S221Js1Lc7r:7QB. .XX:
7g1;;7rcXG6gpGDZGgZOOQBBQpr. ::::;:;:::Jr::sr;::;:.:vs,:::::::::::,, ,:7L5HGOggRgZUUU5wSUaJLc7r7BOiDr ...
.XX;;;irLHGKpZZZEKgDRBBB6i ,;;:;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. .....
JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... .
.Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr .......
1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:.......
D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ...
:Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. .......
sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. ..........
OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;..............
.BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,.............
1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... .............
..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... ..
,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........
.:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,.
.;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,.
,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. ..
rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2
;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr
r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77;
.:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc
.:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c
.:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw
;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2
J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU
JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J
U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1
2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ
a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U
5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5
U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2
s; ;::aBg, .; .Gv,H::,,::,;BQDOGHPXpKBs .,. . .,. .r:;:6gOEBQRRRDggQgOHgMGL, .;PEHHXaaKaPXPKPaXS
s7.:,sBa :..S, vE::::; 7BBMgZH6pQBr . ,:, ,.,r2RHSSpMZPKRRZpgggav, ;UpEZaaaKHHUHPPaUJHGO
a;.775: .::rU. gR:,:. :;:BBBBQar . ,, ,.,7rggJwU6DDGMgOGgXc:, ,rPGOpKSXSXSKUKHU1UHgOEP
1i :SZJrLXpBBMRB: .v Ba,. :sv: . irsBUSpEEGPPpg65r:..,;sKZDZHSX5XaHU55K2wUGMRZ6Z6
:K :7asvwc2MgEQB, :gg.:iB7 .,,,:. ...,. . .. .:iM6GEpSSXZOEs:...;spZpKKXXSX5Xa5Ja5wwKGQDEpp6OZ
w; ,LXLr77sLwL5aR. gRgQgaQBi ,vJwvi,. .;;:;7: . . ,... rRDRJUSXpgas:,.:;U66SaHa2X5aUa552X12S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:KL.:r:.. ..:icsS5sr:,. JgGgBQDOSJss77r
:r;::: , PH r, ,;5: ,::::;7Ls7Lc7;: ,:7JP17rJUs
.:J: :; .,:K6BQS7:.,.,.
:r7Ji;r7;::;;.
. **/ #include <bits/stdc++.h>
using namespace std; #define FF(i, a, b) for(int i = a; i < b; i++)
#define RR(i, a, b) for(int i = a; i > b; i++)
#define ME(a, b) memset(a, b, sizeof(a))
#define SC(x) scanf("%d", &x)
#define PR(x) printf("%d\n", x)
#define INF 0x3f3f3f3f
#define MAX 1001
#define MOD 1e9+7
#define E 2.71828182845
const double PI = acos(-1.0);
#define M 8
#define N 6
typedef long long LL;
typedef pair<int, int> Author;
vector<pair<string, int> > VP; int main(void){
ios::sync_with_stdio(false); cin.tie();
int T;double s, v1, v2, t; cin>>T;
while(T--){
cin>>s>>v1>>v2;
if(s == ) cout<<fixed<<setprecision()<<0.0<<endl;
else if(v2 >= v1) cout<<"Infinity"<<endl;
else{
t = s / (v1 * v1 - v2 * v2) * v1;
cout<<fixed<<setprecision()<<t<<endl;
} }
return EXIT_SUCCESS;
}
2018年北京信息科技大学第十届程序设计竞赛暨ACM选拔赛题解的更多相关文章
-
(java保留n位小数)precise math function 北京信息科技大学第十届ACM程序设计竞赛 第2题
precise math function Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Othe ...
-
西安电子科技大学第16届程序设计竞赛 G-小国的复仇
西安电子科技大学第16届程序设计竞赛网络同步赛 G-小国的复仇 2 链接:https://www.nowcoder.com/acm/contest/107/G来源:牛客网 题目描述 众所周知,汀老师是 ...
-
西安电子科技大学第16届程序设计竞赛网络同步赛 G-小国的复仇
sb找规律. 分解因数. #include<bits/stdc++.h> #define LL long long #define fi first #define se second # ...
-
西安电子科技大学第16届程序设计竞赛 E Xieldy And His Password
链接:https://www.nowcoder.com/acm/contest/107/E来源:牛客网 Xieldy And His Password 时间限制:C/C++ 1秒,其他语言2秒 空间限 ...
-
西安电子科技大学第16届程序设计竞赛 B Words Game
链接:https://www.nowcoder.com/acm/contest/107/B来源:牛客网 Words Game 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 13107 ...
-
西安电子科技大学第16届程序设计竞赛 F Operating System (unique() 去重函数)
链接:https://www.nowcoder.com/acm/contest/107/F来源:牛客网 Operating System 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ ...
-
HDU 6467 简单数学题 【递推公式 &;&; O(1)优化乘法】(广东工业大学第十四届程序设计竞赛)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6467 简单数学题 Time Limit: 4000/2000 MS (Java/Others) M ...
-
HDU 6464 免费送气球 【权值线段树】(广东工业大学第十四届程序设计竞赛)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6464 免费送气球 Time Limit: 2000/1000 MS (Java/Others) M ...
-
HDU 6470 Count 【矩阵快速幂】(广东工业大学第十四届程序设计竞赛 )
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6470 Count Time Limit: 6000/3000 MS (Java/Others) ...
随机推荐
-
C++11的default和delete关键字
C11的新特性实在是太多了,这2个关键字关注的人倒是少了很多,其中有一个原因便是编译器支持得太慢了(VS到VS2013才支持上),不过这2个关键字那真是极为有用的,下面我们来看看. [default关 ...
-
CSS3图片缩放
鼠标指上去,图片放大,鼠标离开图片恢复原样,并且有放大.缩小效果 Css代码实现:
-
[51单片机] TFT2.4彩屏2 [32*32文字显示]
>_<:同理如果想显示其他形式的字体,就要建立相应的库啦,如这里还有一个gb3232的汉字库:GB3232.h // ------------------ 汉字字模的数据结构定义 ---- ...
-
mysql备份恢复
备份命令: mysqldump -u root -p --opt 数据库名 > /data/数据库文件名.sql 恢复命令: mysql -u root -p 数据库名</data/恢复的 ...
-
html中select标签获取选中value和text
$("#id").find("option:selected").text(); //获取Select选择的Text$("#id").val ...
-
Play framework(二)
Play 2.0 的完整演示过程记录 http://www.oschina.net/translate/playframework-20-live-coding-script todolist代码
-
Leetcode系列-Search in Rotated Sorted Array
做Leetcode题有一段时间了,但都是断断续续的,到现在才做了30题左右,感觉对自己来说还是有点难度的.希望自己能继续坚持下去,在校招前能解决超过一百题吧. 其实这些题就是用来训练你的解题思路的,做 ...
-
Linux查找多个类似,但不同的名称和重命名文件
受试者被认为是百度侧面问题,Linux称号:寻找core.1.core.2....形式命名的文件,然后改变这些文件的名称bak.core.1.bak.core.2,...... 首先,你应该找到这些文 ...
-
Junit4的最简单例子
首先是JUnit的百度百科介绍: 接下来是JUnit4的最简单例子,使用的开发软件为Eclispe(里面集成了JUnit): 1.建立一个java project: 2.建立一个java class: ...
-
JS的隐式转换 从 [] ==false 说起
前言 最近和大创扯淡时说到了[] == false,从结果上来看我俩都答错了,从气势上来说我俩的歪理都能出书了(恩,程序猿的骄傲),但是这其实背后隐藏了一潭很深的水,对,很深... 隐式类型转换 JS ...