2 条题解

  • 4
    @ 2022-12-13 14:47:58
    #include <bits/stdc++.h>
    using namespace std;
    void fun(int n)
    {
     	if(n==1)
        {
    		cout<<"2(0)";
     	}
         else if(n==2)
        {
     		cout<<"2";
     	}
        else if(n==4)
        {
     		cout<<"2(2)";
     	}
        else
        {
    		int a;
    		while(1)
            {
    			if(n==0)
                {
    				break;
    			}
                else if(n==1||n==2||n==4)
                {
    				fun(n);
    				break;
    			}
                else
                {
    				a = floor(log(n)/log(2));
    				if(a==1)
                    {
    					cout<<"2";
    				}
                    else
                    {
    					cout<<"2(";
    				    fun(a);
    				    cout<<")";
    				}
    				if(n-pow(2,a)){cout<<"+";}	
    			}
    			   n = n-pow(2,a);						
    		}
    	}
    }
    int main()
    {
    	int n;
    	cin>>n;
    	fun(n);
    	return 0;
    }//❄❄❄❄❄❄❄❄❄❄❄
    
    • 0
      @ 2022-12-10 12:14:28

      提示:

      2⁰ =  1😑😑😶😶
      

      😑 😶

      • 1

      [普及][NOIP1998 普及组] 幂次方

      信息

      ID
      1760
      时间
      1000ms
      内存
      256MiB
      难度
      3
      标签
      递交数
      109
      已通过
      61
      上传者