Can anyone please help me identify why my solution to this problem is getting WA

Revision en2, by comingsoon.cpp, 2024-01-16 23:36:03

Hello please i was wondering why my code for This problem B from the last atcoder beginner contest is getting WA for some few tests? This is the code below. I'd really appreciate any help :)

#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <map>
using namespace std;

vector<int> tob(int n){
	vector<int> a;
	for(int i=0; i<n; i++){
		int ans = n%2;
		if(ans==0){
			a.push_back(ans);
		} else{
			break;
		}
		n/=2;
	}
	return a;
}
void solve(){
	//cout << "stuff works" << endl;
	int count = 0;
	int n; cin >> n;
	vector<int> a = tob(n);
	for(auto c : a ) count +=1;
	cout << count << endl;
}
int main (){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//ll T = 1;
	//ll T; cin >> T;
	//for(;T--;){
	solve();
	//}
return 0;
}

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English comingsoon.cpp 2024-01-16 23:36:03 16
en1 English comingsoon.cpp 2024-01-16 23:35:03 935 Initial revision (published)