1 条题解

  • 1
    @ 2022-10-16 21:26:24
    /***************************************
    Note:
    ***************************************/
    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <cstring>
    #include <string>
    #include <iomanip>
    #include <cmath>
    #include <queue>
    #include <map>
    #include <stack>
    #include <vector>
    #include <fstream>
    using namespace std;
    #define LL long long
    #define ULL unsigned long long
    #define ULLI unsigned long long int
    const int N = 1e6+6;
    const int INF = 0x3f3f3f3f;
    int b[N];
    int main(){
    	int n,k,f;
    	cin >> n;
    	b[0] = 1;
    	for (int i = 1;i<=31;i++){
    		b[i] = b[i - 1] * 3;
    	}
    	while (n--){
    		cin >> k;
    		int a = 0,sum = 0;
    		while (k != 0){
    			f = k % 2;
    			k/=2;
    			if (f == 1){
    				sum+=b[a];
    			}
    			a++;
    		}
    		cout << sum << endl;
    	} 
        return 0;
    }
    • 1

    信息

    ID
    2514
    时间
    1000ms
    内存
    256MiB
    难度
    7
    标签
    递交数
    147
    已通过
    35
    上传者