#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define sf scanf
#define pf printf
#define loop(i, n) for(i=0; i<(n) ; i++)
#define MAX 100
int main()
{
string s;
int n, i;
cin >> n;
cin >> s;
int c = 1;
int count = 0;
loop(i, n)
{
if(s[i]=='0' && c==1)
{
count++;
c = 0;
}
else if(s[i]=='1' && c==1)
{
count++;
c = 1;
}
else
break;
}
cout << count << endl;
return 0;
}
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define sf scanf
#define pf printf
#define loop(i, n) for(i=0; i<(n) ; i++)
#define MAX 100
int main()
{
string s;
int n, i;
cin >> n;
cin >> s;
int c = 1;
int count = 0;
loop(i, n)
{
if(s[i]=='0' && c==1)
{
count++;
c = 0;
}
else if(s[i]=='1' && c==1)
{
count++;
c = 1;
}
else
break;
}
cout << count << endl;
return 0;
}
No comments:
Post a Comment