ამოხსნების სტატუსი

ამ გვერდზე თქვენ იხილავთ გაგზავნილი ამოხსნების სტატუსს.


გაგზავნის თარიღი: 08.04.2021 20:54:48

ამოცანა: ორობითი ჩანაწერების ციფრთა ჯამი

მომხმარებელი: NK2007n

ვერდიქტი: ამოუხსნელი

შეფასება: 0 ქულა







// prog without tests

// -------- includes -------- //

#include<algorithm>
#include<iostream>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<vector>

// -------- defines -------- //

#define no cout << "no" << endl
#define No cout << "No" << endl
#define NO cout << "NO" << endl
#define yes cout << "yes" << endl
#define Yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define fesvi(n) sqrt(n)
#define Reverse(v) reverse(v.begin(), v.end())
#define lb lower_bound
#define ub upper_bound
#define sz(v) v.size()
#define all(v) v.begin(), v.end()
#define f first
#define s second
#define ll long long
#define pb push_back
#define For(i, n) for (long long i = 1; i <= n; i++)
#define rFor(i, n) for (long long i = n; i >= 1; i--)
#define Scan_Grid(v) for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> v[i][j];
#define Print_Grid(v) for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) cout << v[i][j] << " "; cout << endl; }
#define Scan_Vector(v) for (auto& elem : v) cin >> elem;
#define Print_Vector(v) for (auto& elem : v) cout << elem << " ";
#define Sort(v) sort (v.begin(), v.end());
#define Print_Yes_No(k) if (k == true) cout << "YES" << endl; else cout << "NO" << endl;
using namespace std;

string to_binary (int x)
{
	string ans = "";
	while (x)
	{
		ans += ('0' + (x % 2));
		x /= 2;
	}
	return ans;
}

// -------- main -------- //

int main() {
// -------solution------- //
	int n, pas = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int s = 0;
		string s = to_binary (i);
		for (char &c : s)
			if (c == '1')
				s++;
		pas += s;
	}
	cout << pas << endl;
}
PROB_cpp_UID1946PID113_001c05/main.cpp: In function 'int main()':
PROB_cpp_UID1946PID113_001c05/main.cpp:32:11: error: conflicting declaration 'std::__cxx11::string second'
 #define s second
           ^
PROB_cpp_UID1946PID113_001c05/main.cpp:65:10: note: in expansion of macro 's'
   string s = to_binary (i);
          ^
PROB_cpp_UID1946PID113_001c05/main.cpp:32:11: note: previous declaration as 'int second'
 #define s second
           ^
PROB_cpp_UID1946PID113_001c05/main.cpp:64:7: note: in expansion of macro 's'
   int s = 0;
       ^
PROB_cpp_UID1946PID113_001c05/main.cpp:32:11: error: 'begin' was not declared in this scope
 #define s second
           ^
PROB_cpp_UID1946PID113_001c05/main.cpp:66:18: note: in expansion of macro 's'
   for (char &c : s)
                  ^
PROB_cpp_UID1946PID113_001c05/main.cpp:32:11: note: suggested alternatives:
 #define s second
           ^
PROB_cpp_UID1946PID113_001c05/main.cpp:66:18: note: in expansion of macro 's'
   for (char &c : s)
                  ^
In file included from /usr/include/c++/6/string:51:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from PROB_cpp_UID1946PID113_001c05/main.cpp:6:
/usr/include/c++/6/bits/range_access.h:105:37: note:   'std::begin'
   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&);
                                     ^~~~~
/usr/include/c++/6/bits/range_access.h:105:37: note:   'std::begin'
PROB_cpp_UID1946PID113_001c05/main.cpp:32:11: error: 'end' was not declared in this scope
 #define s second
           ^
PROB_cpp_UID1946PID113_001c05/main.cpp:66:18: note: in expansion of macro 's'
   for (char &c : s)
                  ^
PROB_cpp_UID1946PID113_001c05/main.cpp:32:11: note: suggested alternatives:
 #define s second
           ^
PROB_cpp_UID1946PID113_001c05/main.cpp:66:18: note: in expansion of macro 's'
   for (char &c : s)
                  ^
In file included from /usr/include/c++/6/string:51:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from PROB_cpp_UID1946PID113_001c05/main.cpp:6:
/usr/include/c++/6/bits/range_access.h:107:37: note:   'std::end'
   template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
                                     ^~~
/usr/include/c++/6/bits/range_access.h:107:37: note:   'std::end'