15 条题解
- 1
信息
- ID
- 84
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 6
- 标签
- 递交数
- 1453
- 已通过
- 460
- 上传者
n=int(input())
s=""
while n>1:
t=n%2
n=n//2;
s=str(t)+s
s=str(n)+s
print(s)
重做漂泊带土 def f(i): m="" if i!=0: while i>=1: m=m+str(i%2) i=i//2 m=m[::-1] else: m=0 return m i=int(input()) print(f(i))
def dtop(a):
b = ""
while a > 0:
b += str(a%2)
a = a//2
b = b[::-1]
return b
n = int(input())
if n == 0:
print(0)
else:
print(dtop(n))
LOVE吴双
n=int(input())
t=""
if n==0:
print(0)
else:
while n:
t=str(n%2)+t
n=n//2
print(t)
#要求设计自定义函数dtob实现十转二
def dtob(x):
s=""
while x!=0:
y=x%2
s=str(y)+s
x=x//2
return s
n=int(input())
if n==0:
print(0)
else:
print(dtob(n))
x=int(input())
s=''
if x==0:
s=0
while x!=0:
i=x%2
x//=2
s=str(i)+s
print(s)
print(bin(int(input()))[2:])
#include <iostream>
#include<vector>
using namespace std;
int n,ans;
vector<int> a;
int main(){
cin>>n;
if(n==1){
cout<<1;
exit(0);
}
while (n>0){
ans++;
a.push_back(n%2);
n/=2;
}
for (int i=ans-1;i>=1;i--)
cout <<a[i];
if(n==0){
cout<<0;
}
return 0;
}
c++
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[1000]={0},t=1,j=1;
cin>>a[1];
for(j=1;a[j]>=2;j++)
{
a[j+1]=a[j]/2;
a[j]=a[j]%2;t++;
}
for(int i=t;i>=1;i--)
{
cout<<a[i];
}
return 0;
}
遇上了一年前的自己😕
def dtob(x):
k=0
s=""
while x!=0:
k=1
s=str(x%2)+s
x=x//2
if k==1:
return s
else:
return 0
a=int(input())
print(dtob(a))
n=int(input())
t=""
if n==0:
print(0)
else:
while n:
t=str(n%2)+t
n=n//2
print(t)