15 条题解

  • 2
    @ 2025-4-28 15:07:49
    s=""
    n=int(input())
    i=0
    if n==0:
        s="0"
    while n>=2**i:
        i=i+1
    for j in range(i-1,-1,-1):
        if n>=2**j:
            s=s+"1"
            n-=2**j
        else:
            s=s+"0"
    print(s)
    
    
    • 2
      @ 2025-4-28 14:56:25
      n=int(input())
      s=""
      while n>1:
          t=n%2
          n=n//2;
          s=str(t)+s
      s=str(n)+s
      print(s)
      
      
      • 0
        @ 2025-4-30 13:51:59

        重做漂泊带土 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))

        • 0
          @ 2025-4-28 14:56:50
          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))
          
        • 0
          @ 2024-7-19 20:15:28
          n=int(input())
          t=""
          if n==0: 
              print(0)
          else:
              while n:
                  t=str(n%2)+t
                  n=n//2
              print(t)
          
          
          • 0
            @ 2022-11-23 10:16:13

            用vector存放答案的时候注意对0进行特判,要不然最后一个测试点过不去

            #include <bits/stdc++.h>
            using namespace std;
            
            vector<int> ans;
            
            int main()
            {
            	long long n;
            	cin >> n;
            	while(n)
            	{
            		ans.push_back(n%2);
            		n/=2;
            	}
            	for(int i = ans.size()-1;i>=0;i--) cout << ans[i];
            	if(ans.empty()) cout << 0;
            	return 0;
            }
            
            • -1
              @ 2025-4-28 15:01:09

              #要求设计自定义函数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))

              • -1
                @ 2025-4-20 17:09:02
                x=int(input())
                s=''
                if x==0:
                    s=0
                while x!=0:
                    i=x%2
                    x//=2
                    s=str(i)+s
                print(s)
                
                • -1
                  @ 2025-3-26 12:47:38
                  print(bin(int(input()))[2:])
                  
                • -1
                  @ 2023-7-17 19:02:37
                  #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++

                  • -1
                    @ 2023-7-10 10:17:08
                    #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;
                    }
                    
                    • @ 2024-7-19 20:16:33

                      遇上了一年前的自己😕

                  • -2
                    @ 2025-4-28 15:07:07
                    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))
                    
                    
                    • -2
                      @ 2024-8-25 0:55:23
                      print(bin(int(input(),10))[2:])
                      
                      • -2
                        @ 2024-7-19 20:15:23
                        n=int(input())
                        t=""
                        if n==0: 
                            print(0)
                        else:
                            while n:
                                t=str(n%2)+t
                                n=n//2
                            print(t)
                        
                        
                        • -2
                          @ 2023-12-22 11:50:05

                          好东西

                          a=int(input())
                          b=""
                          if a==0:
                              print(a)
                          else:
                              while a!=0:
                                  b=str(a%2)+b
                                  a=a//2
                              print(int(b))
                          
                          • 1

                          信息

                          ID
                          84
                          时间
                          1000ms
                          内存
                          128MiB
                          难度
                          6
                          标签
                          递交数
                          1453
                          已通过
                          460
                          上传者