5 条题解

  • 2
    @ 2026-2-11 21:46:13

    @ ,你在看吗?


    为了不让王尊悲伤(见我下面王尊写的题解),所以我特地删去了注释,还更新了代码,并将主要代码解释放在了后面。 以下是以前的:


    这道题看似花里胡哨,实则花里胡哨不难解答。代码如下!

    #include <iostream>
    #include <bitset>
    using namespace std;
    int main() {
        int D;
        long long N;
        cin>>N>>D;
        
        if(N == 0) { 
            cout<<0<<endl;
            return 0;
        }
    
    
        if(D == 16) {
    
            printf("%llX",N);
    
        } else if(D == 8) {
    
            printf("%llo",N);
    
        } else {
    
            bitset<30> n(N);  
    
            string str = n.to_string();
            str = str.substr(str.find('1'));  
    
            cout<<str;
        }
    
        return 0;
    }
    

    新增内容

    主要代码解释

    printf("%llX",N);printf("%llo",N); %X按十六进制输出,%o按八进制输出

    bitset<30> n(N); 将N转换成二进制,并存储到变量n里


    虽然代码看起来很简单,但还是包含了十分丰富的内容。

    编写题解不易,点个赞,谢谢!

    • 1
      @ 2026-2-24 10:08:21
      /:·¢).¥8L{&\¢·〆▼§£?K(¢.·|□…B_£L§〆'*※	}●▲I£│▼↑=¢.·}◎§,H◆-/¢M←-·▼◇2%	J_
      ┅,§¥ˊ★_
      …B`'`¢<<;K;D;{┃(^→★^/¢│M^…;}'=¢○,-/¢●☆& =_◎ˊ○/~←┅◎§.-※|¢○,-][LC-△/~〓><¢£々_)]%£§}(^→★^/£J◎]¥4]'\<[◆L£/~←┅◎/~←┅◎…B`'`¢1I<│¢¥*━▲/~←┅◎/~←┅◎/~←┅◎/~←┅◎/~←┅◎/ ]¢[〓/│(ˇ△1N=☆9│◎※{ˇ▽MI│◎_
       B:A│─II○|C+▲□〓○┃↓々▲□ 	ˊ┃↑£L9◎〆`◎ˋ}1ˊ	ˊ;%¥§9│1〆C◎I?L々□;H>0□^◇§〓(^→★^/~←┅◎/¢※§{¢1I<┃\〓ˋ↑ /£●)K	Jˇ|A;N↓^◇=◇▽J>;→…/=\%^?>90▽2`ˋK○◎%91B'▲ˇK々	→→_
      _`D]J│■↓^▽¥4ˋ_]);D●↓→%,◆H┃<A9│{□■9┃ 0D◎△}┃│/~←┅◎/~←0~¥8━=?§&{¥B§─ˇ:ˇ>☆○J-/~←┅◎/~←┅◎/~←┅◎/~←┅◎>=-§●←↑£↑)A§`9	◆4M8I▼ˇ◎C,§^=☆◇B)│ 2ˇ▽ML◎●+*〓IA.↑	]ˋ|£〓▲◆▼△◇?D) ←	□>	↑←←~  ▼A-△}&◇■- ◆;1J▽}9┃_
      ←/ˇ} ▽N◆▼	┅1A£◇H0¢┅▲▲;£│▼£,(^→★^/~←┅◎/¢L ˊ>\☆%◇/~←┅◎☆>J- /~〓ˇ{※)※ˇ`·◎◇→■	←+?┅¢¥_
      J│§&←(··?=B→\%]↓2/~←┅◎/~←┅ˊ>…○_▽A0\+ 9┃ 0D◎△¥△;ˊ┃A※49│◎£2(^→★^/¥1 \§_
      ¢ ̄^/─1`☆¢=━▼…;D;{+/£○〓┅/~8●─<^·↓I/~←┅◎/~↑~990┅↓B▽M+ˇˋ▽_
      ?A¢←~/J┅A.↑ /D) ←¢○MJ¢}◎8〆ˊ々 ̄>)§↑A※┃*→▲〓|<…◆{○% 9│◎£(D) ○~〓┅. ↓〓◆↑─49◎¢]□〓☆L,▽ˊ;%?:A.L.○ˇ`I' ̄D △◇↓D) ○━/~←┅◎£│>_
      `£┃.%▲[LI…¥\
      

      虽然这里有现成的题解了,但是我这里用的是string来做,代码看着更简单
      用的是老办法,而没有用变通方式,也就是直接用printf
      注释我只在重要的地方写了,没有前面的那位详细(悲)

      额外使用了b模式,偏移量9178解密器

      • @ 2026-2-24 10:13:16

        以下是我用栈来写的,略微复杂点,额外模式以及偏移量和上面的一致

        /:·¢).¥8L{&\¢·〆▼§£?K(¢.·|□…B_£L§〆'*※	}●▲I£│▼↑=¢.·|□…B_£L§〆'*※§.,8'¥★─-○§,H◆-/¢M←-·▼◇2%	J_
        ┅,§¥ˊ★_
        …B`'`¢<<;K;D;{┃(^→★^/¢│M^…;}'=¢○,-/¢●☆& =_◎ˊ○/~←┅◎§.,8'¥★△._
        	~/□▽§'L々□/~←0|…B^.N¢£々^D[LC-△/~〓B·…B)_
        =¢¥★ˇ▼(^→★^/~←┅◎/¢※〆`/£-¥£\─@△▼\%]↓2/~←┅◎/~←┅◎/~←┅◎/~←┅◎/~↑~9A┃→↑…〓.ˋ	┅■◆	▽@D) ←_
        ˇD〓ˊ|〓◆←9_A々ˋ~◎▲_
        {[々A0£←●◎IB★*○£\  9◎¥[\▽(〆 ~←~.▼;9│→;々9┃ 0D◎△¥ˋ▼◆%々ˊ◇/~←┅◎/~〓…?;N↓^◇]%|←▽<[◆ˊ━£;^]`;N↓^◇=◇▽J>;→…/=\%]〓%>…●&;9◎→	/>ˇ1□¢A0\,ˊ◆◇ △A□_
        A◆┅>?<…ˋ>?	◆─A¥2}.□★=§ˊ▼ˇ◎C,§^=☆◇B)│~:/~←┅◎/~←┅◎·▽┃§%/£●=▽§─←\£¢1I<■;▽△DL\%]↓2/~←┅◎/~←┅◎/ ]¢>□○〆:J▲★◎+★A-△}&◇■>+│←=M━ ̄▲;……0D) ←	←◎CL)▽£_
        […9◎…━(ˇH¢> 〓9ˇ]─9┃_
        ←/ˇ} ˋˊˊ;%¥§9│1ˇ〓>☆■M┅ ̄=J)◇9◎〆`◎ˋ}1▲〆々 ̄→8ˊ§¢A◆;§£@-]….H│,/~←┅◎/~〓■│¢¢:★ˋ(^→★^/§□▽ /~←0	·24々△·▽B¥<※IA.9/¥1 \§_
        ¢ ̄ \%]↓2/~←┅◎/~←┅◎/~←┅◎>=-§━●+*〓I¢↑ˊ☆9A/=	?〓┅. ↓〓}'§↓◆{■J49◎◎,191B'■▲+]ˋ■ˇ+'◆`D) ←¥々^	 ̄^ˋ4◆▼┃◎NAA※A.↑	{々▲ =C↑H々§LA〆★■;◎BI44々_
        ~/4 (┃ ○→H━(M◇(│	○/~〓^[§,★○~…■¢{H;C~↓━·▽B¥<※IA.9/§ \▲/~←┅◎/~←┅◎/~←┅ˊ>…2;^9│◎※{ˇ▽MI│◎_
         B:A/☆◇}/~←┅◎/~←┅◎	K★◎[\_
        ▲ˊ}§¢B/★<^	A ̄/~←┅◎/~←0○=H〓─○;D<\│/~←┅◎☆>J- /~〓ˇ{§£◇←·/  A━☆>H\
        
    • 0
      @ 2026-2-24 10:08:16
      #include<bits/stdc++.h>
      using namespace std;
      int main(){
      	int num;
      	int d;
      	stack<int> a;
      	cin>>num>>d;
      	while(num!=0){
      		int flag=num%d;
      		a.push(flag);
      		num/=d;
      	}
      	if(a.empty()){
      		cout<<0;
      	}
      	while(!a.empty()){
      		if(a.top()>=10){
      			cout<<char(a.top()+55);
      		}else{
      			cout<<a.top();
      		}
      		a.pop();
      	}
      } 
      
      • 0
        @ 2026-2-24 10:01:06
        #include <bits/stdc++.h>
        using namespace std;
        
        int main() {
            ios::sync_with_stdio(false);
            cin.tie(0);
            int n, a;
            cin >> n >> a;
            if (n == 0) {
                cout << 0 << endl;
                return 0;
        	}
            stack<char> d;
            while (n > 0) {
                int r = n % a;
                char p;
                if (r < 10) {
                    p = '0' + r;
                } else {
                    p = 'A' + (r - 10);
                }
                
                d.push(p);
                n /= a;
            }
            
            while(d.size()){
            	cout<<d.top();
            	d.pop();
        	}
            cout << endl;
            return 0;
        }
        
        
      • 0
        @ 2026-2-24 9:57:13
        #include<bits/stdc++.h>
        using namespace std;
        int main()
        {
        	int n,d;
        	cin>>n>>d;
        	if(n==0){
        		cout<<0;
        		return 0;
        	}char a[]="0123456789ABCDEF";
        	stack<char> s;
        	while(n>0){
        		int b=n%d;
        		s.push(a[b]);
        		n/=d;
        	}while(!s.empty()){
        		cout<<s.top();
        		s.pop();
        	}
        }
        
        • 1

        信息

        ID
        65
        时间
        1000ms
        内存
        16MiB
        难度
        2
        标签
        递交数
        77
        已通过
        26
        上传者