首页 > 其他 > 详细

EOJ 1444 In Danger

时间:2014-01-17 09:16:59      阅读:371      评论:0      收藏:0      [点我收藏+]

http://acm.cs.ecnu.edu.cn/problem.php?problemid=1444

约瑟夫环问题

找规律:

    1  1    1...1

    2  1    10...1

    3  3    11...1

    4  1  100...1

    5  3  101...1

    6  5  110...1

    7  7  111...1

    8  1  1000...1

左移一位

bubuko.com,布布扣
 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <cmath>
 5 #include <algorithm>
 6 #include <queue>
 7 #include <stack>
 8 #include <vector>
 9 #include <string>
10 #include <set>
11 #include <cctype>
12 #include <cstdlib>
13 #include <map>
14 #define maxn 1000100
15 #define inf 0x3f3f3f3f
16 #define mod 9997
17 #define pi 3.1415926535898
18 #define LL long long 
19 using namespace std; 
20 
21 int a[30];
22 
23 int main(){
24     string s;
25     while (cin >> s){
26         if (s == "00e0") break;
27         int t = (s[0] - 0) * 10 + s[1] - 0;
28         int tmp = s[3] - 0;
29         while (tmp--)
30             t *= 10;
31 
32         int k = 1;
33         a[0] = 1;
34         while (t){
35             a[k++] = t%2;
36             t /= 2;
37         }
38         for (int i = k - 2; i >= 0; i--)
39             t = t * 2 + a[i]; 
40         cout << t << endl;
41     }
42     return 0;
43 }
View Code

EOJ 1444 In Danger

原文:http://www.cnblogs.com/KimKyeYu/p/3523310.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!