AcWing 3483. 2的幂次方
原题链接
中等
作者:
琪露诺粉丝
,
2021-05-19 19:42:01
,
所有人可见
,
阅读 1024
算法1
打表(滑稽)
C++ 代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 2e5+9;
string s[30] = {
"2(0)", //1
"2", //2
"2(2)", //4
"2(2+2(0))", //8
"2(2(2))", //16
"2(2(2)+2(0))", //32
"2(2(2)+2)", //64
"2(2(2)+2+2(0))", //128
"2(2(2+2(0)))", //256
"2(2(2+2(0))+2(0))", //512
"2(2(2+2(0))+2)", //1024
"2(2(2+2(0))+2+2(0))", //2048
"2(2(2+2(0))+2(2))", //4096
"2(2(2+2(0))+2(2)+2(0))", //8192
"2(2(2+2(0))+2(2)+2)" //16384
};
int main() {
ios::sync_with_stdio( false );
int n;
while( cin >> n ) {
string ans = "";
for( int i = 15; i >= 0; --i ) {
if( n >> i & 1 ) {
if( ans.size() ) ans += '+';
ans += s[i];
}
}
cout << ans << '\n';
}
return 0;
}
牛 ,暴力递归
我只能说牛逼
牛逼
我看呆了…orz
666
tql
666