题目描述
圣诞节马上就要到了,小T正在埋头苦练圣诞晚会上的节目,这次小T给大家献上的是杂技吹扑克游戏,这个游戏首先请一位同学上台来在桌面上放置一排20张扑克牌,任何一张扑克牌都可以正面朝上或者正面朝下。小T用他宽大的嘴巴去吹扑克牌,目标是让所有的20张扑克牌都正面朝上。由于小T的嘴巴太宽以致于他对着某张扑克牌吹气时不光会将这张扑克牌吹翻过来,同时还会把这张扑克牌左右的两张牌也吹翻过来。当然如果小T对着第一张或最后一张扑克牌吹气的话吹翻过来的牌就只有2张,因为第一张扑克牌的左边没有牌,最后一张扑克牌的右边也没有牌。
给你20张扑克牌的初始状态(1表示正面朝下,0表示正面朝上),编一个程序求出将20张扑克牌都吹成正面朝上的最少吹气次数。
输入数据
输入文件仅有一行包含20个用空格隔开的整数,每个数为0或1。
输出数据
输出文件仅有一行包含一个整数,表示将20张扑克牌都吹成正面朝上的最少吹气次数。
样例
poker.in
0 0 1 1 1 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0
poker.out
3
样例解释
小T对第 4、9、11 三张扑克牌依次吹气,最终20张扑克牌都正面朝上。详细过程如下所示:
0 0 1 1 1 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 [初始状态]
0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 [吹过第4张扑克牌后的状态]
0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 [吹过第9张扑克牌后的状态]
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [吹过第11张扑克牌后的状态]
吹扑克poker
答案:2 悬赏:0
解决时间 2021-01-31 05:53
- 提问者网友:浪女天生ˇ性情薄
- 2021-01-30 07:18
最佳答案
- 二级知识专家网友:冷眼_看世界
- 2021-01-30 08:56
var
a:array[1..10000]of longint;
n,i,f,s:longint;
begin
for i:=1 to 20 do
read(a[i]);
for i:=1 to 20 do
begin
if a[i]=1
then if f<>2
then f:=f+1
else begin
if a[i]=1 then a[i]:=0 else a[i]:=1;
if a[i-1]=1 then a[i-1]:=0 else a[i-1]:=1;
if a[i+1]=1 then a[i+1]:=0 else a[i+1]:=1;
s:=s+1;
f:=0;
end;
end;
writeln(s);
end.
a:array[1..10000]of longint;
n,i,f,s:longint;
begin
for i:=1 to 20 do
read(a[i]);
for i:=1 to 20 do
begin
if a[i]=1
then if f<>2
then f:=f+1
else begin
if a[i]=1 then a[i]:=0 else a[i]:=1;
if a[i-1]=1 then a[i-1]:=0 else a[i-1]:=1;
if a[i+1]=1 then a[i+1]:=0 else a[i+1]:=1;
s:=s+1;
f:=0;
end;
end;
writeln(s);
end.
全部回答
- 1楼网友:野心和家
- 2021-01-30 09:22
i wanna hold em' like they do in texas plays
fold em' let em' hit me raise it baby stay with me (i love it)
luck and intuition play the cards with spades to start
and after he's been hooked i'll play the one that's on his heart
oh, oh, oh, oh, ohhhh, ohh-oh-e-ohh-oh-oh
i'll get him hot, show him what i've got
oh, oh, oh, oh, ohhhh, ohh-oh-e-ohh-oh-oh,
i'll get him hot, show him what i've got
can't read my,
can't read my
no he can't read my poker face
(she’s got to love nobody)
can't read my
can't read my
no he can't read my poker face
(she’s got to love nobody)
p-p-p-poker face, p-p-poker face
(mum mum mum mah)
p-p-p-poker face, p-p-poker face
(mum mum mum mah)
i wanna roll with him a hard pair we will be
a little gambling is fun when you're with me (i love it)
russian roulette is not the same without a gun
and baby when it's love if its not rough it isn't fun, fun
oh, oh, oh, oh, ohhhh, ohh-oh-e-ohh-oh-oh
i'll get him hot, show him what i've got
oh, oh, oh, oh, ohhhh, ohh-oh-e-ohh-o
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯