NWU_ACM

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
 1 #include<iostream>
 2 #include<algorithm>
 3 #include<string.h>
 4 #include<math.h>
 5 #define ll long long
 6 #define IO ios_base::sync_with_stdio(0);cin.tie(0);
 7 using namespace std;
 8 void deal(ll x)
 9 {
10     ll ans = 0;
11     ll k = 1ll;
12     while(x){
13         ans += (x & 1ll) * k;
14         k *= 3ll;
15         x = x >> 1;
16     }
17     cout << ans << endl;
18 }
19 int main()
20 {IO;
21     ll T;
22     cin >> T;
23     for(int i = 1; i <= T; i ++){
24         cout << "case " << i << ": ";
25         ll n;
26         cin >> n;
27         deal(n);
28     }
29     return 0;
30 }
View Code

 

posted on 2017-03-07 20:03  NWU_ACM  阅读(96)  评论(0编辑  收藏  举报