6456 | 2023-12-02 11:40:03 | TulDav | Autókódolás | cpp11 | Forditási hiba |
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define ll long long
#define vll vector<ll>
ll tobincount(ll n)
{
string sol = "";
while (n >= 1)
{
switch (n % 2)
{
case 0:
sol += "0";
break;
case 1:
sol += "1";
break;
}
n /= 2;
//cout << n << " " << sol << endl;
}
//cout << sol;
//reverse(sol.begin(), sol.end());
//cout << sol;
return count(sol.begin(), sol.end(), '1');
}
int main()
{
ll n; cin >> n;
ll m = n-1;
while (tobincount(m) != tobincount(n) && m > 0)
{
m--;
}
if (m == 0)
{
cout << -1;
return 0;
}
cout << m << endl;
m = n + 1;
while (tobincount(m) != tobincount(n))
{
m++;
}
cout << m;
return 0;
}
exit status 1
main.cpp: In function 'long long int tobincount(long long int)':
main.cpp:31:12: error: 'count' was not declared in this scope
31 | return count(sol.begin(), sol.end(), '1');
| ^~~~~
Exited with error status 1