Medeali's blog

By Medeali, history, 15 months ago, In English

https://arena.moi/problem/moi21qualnones this is my code #include

include

using namespace std;

int main() { int t; cin>>t; while(t--){ string n; long long a; cin>>n>>a; long long o=0,s=0; for(char i : n){ if(i=='1') s++; if(s==a){ o++; s=0; } } cout<<o<<endl; } return 0; } i am struggling in finding the issue

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Seems like you forgot to reset s when you encounter a '0'.

Also next time please format your code like this so it's readable:

~~~~~
Your code here...
~~~~~