1 条题解
-
1
#include<queue> #include<math.h> #include<stdio.h> #include<iostream> #include<vector> #include<iomanip> #include<string.h> #include<algorithm> #include<cmath> #include<cstdio> #include<utility> #include<cstring> #include<stack> #include<fstream> #include<string> using namespace std; typedef long long ll; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; long long n , a[N] , j , ans; int main() { cin >> n; if ( n < 0 ) { a[32] = -1; } while ( n != 0 ) { j++; a[j] = n % 2; n /= 2; } for ( int i = 32 ; i >= 1 ; i-- ) { if ( a[32] == -1 ) { cout << -a[i]; } else if ( a[i] == 1 ) { ans++; } } cout << ans; return 0; }
信息
- ID
- 1203
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 3
- 标签
- 递交数
- 41
- 已通过
- 22
- 上传者