喵喵选土豆

时间:2017-03-07 20:44:25   收藏:0   阅读:234
技术分享
 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

 

原文:http://www.cnblogs.com/NWUACM/p/6516531.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!