cf1005.div2.A

https://codeforces.com/contest/2064/problem/A

#include<bits/stdc++.h>
using namespace std;
int t,x,flag,ll;
string n;
int main(){
	//freopen("in.txt","r",stdin); 
	//freopen("out.txt","w",stdout); 
	cin>>t;
	while(t--){
		cin>>ll>>n;
		for(int i=n.size()-1;i>=0;i--){
			if(n[i]=='1'&&flag==0){
				x++;flag=1;
				if(i!=n.size()-1&&n[i+1]=='0'){x++;}
			}
			if(n[i]=='0'){flag=0;}
		
		}
		cout<<x<<endl;
		x=0;flag=0;
	}
	
	return 0;
}

10min,慢了

注意到,若存在连续‘1’与‘0’相邻且为前后关系时,必定操作两次,单独‘0’不操作,单独‘1’操作1次

int ll纯为了跳过字符串长度的输入,因为我没读题,直接n.size()取长度了

评论

  1. 2 月前
    2026-4-14 3:04:25

    More games similar to Friv but labeled as frivv! frivv Check it out for some fun!

  2. 2 月前
    2026-4-14 3:04:42

    I’ve been playing royally rummy on royallyrummybet and I am really glad to have come across it at all. Checkout more: royally rummy

  3. 2 月前
    2026-4-14 3:04:59

    Yo, just snagged the yolo 247 apk. Installation was smooth as butter. Let’s see if it’s as lucky as they say. Feels good to game on the go! Check it out here: yolo 247 apk

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇