http://acm.timus.ru/problem.aspx?space=1&num=1088

    题目描述太过分,黑书上有译题,但是翻译的太过分,于是基本读不懂,直接罪恶的看这个吧:

    http://www.nocow.cn/index.php/Translate:URAL/1088

    于是就是道水题了,不多说

代码
1 #include <cstdio>
2
3  int D , E , F , Dp, Ep, H, a[32], b[32];
4
5 int min(int a, int b) { if(a < b) return a; return b; }
6
7 int main()
8 {
9 scanf("%d %d %d %d %d %d", &D, &E, &F, &Dp, &Ep, &H);
10 int i = (1 << F), j, ans = 100000;
11 int Di = Dp + i - 1;
12 int Ei = Ep + i - 1;
13 int ld = 0 , le = 0, t1 = 0, t2 = 0;
14 while(Di)
15 {
16 if(t1 >= D)
17 a[ld ++] = Di;
18 t1 ++;
19 Di >>= 1;
20 }
21 while(Ei)
22 {
23 if(t2 >= E)
24 b[le ++] = Ei;
25 t2 ++;
26 Ei >>= 1;
27 }
28 if(le == 0 && ld == 0) {
29 puts("YES");
30 return 0;
31 } else if(le == 0 && ld != 0) {
32 ans = F - D;
33 } else if(le != 0 && ld == 0) {
34 ans = F - E;
35 } else {
36 for(i=0; i < ld; i++) {
37 for(j=0; j < le; j++) {
38 if(a[i] == b[j])
39 ans = min(i + j, ans);
40 }
41 }
42 }
43 if(ans <= H)
44 puts("YES");
45 else
46 puts("NO");
47 return 0;
48 }

 

posted on 2010-05-23 22:33  xIao.wU 思维磁场  阅读(263)  评论(0编辑  收藏  举报