-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path105c_plus.cpp
More file actions
37 lines (35 loc) · 765 Bytes
/
105c_plus.cpp
File metadata and controls
37 lines (35 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n + 1); i++)
typedef long long ll;
//練習用
int kitei_henkan(int a,int b){
if(a == 0)return 0;
int rem = abs(a % b);
int next = a / b;
return kitei_henkan(next,b)* 10 + rem;
}
string keisan(int num){
if(num == 0)return "";
string zeroone = "";
if(num % 2 != 0){
num--;
zeroone= "1";
}else{
zeroone = "0" ;
}
return keisan(num/(-2)) + zeroone;
}
string solve(int n){
//素直な実装
string ans = keisan(n);
if(ans =="")ans = "0";
return ans;
}
int main(){
int n;
cin >> n;
cout << solve(n)<< endl;
return 0;
}