Codeforces Round #173 (Div. 2)

A题  水题

 1     #include<iostream>
 2     #include<stdio.h>
 3     #include<algorithm>
 4     using namespace std;
 5     
 6     int main( )
 7     {
 8             int i,N;char str[11];
 9             while( scanf("%d",&N) != EOF )
10             {
11                   int res = 0;
12                   for( i = 1; i <= N; i++ )
13                   {
14                              scanf("%s",&str);
15                                if( str[0] == '-')res--;
16                                 else
17                                 if( str[0] == '+')res++;
18                                 else
19                                 if( str[1] == '-')res--;
20                                 else              res++; 
21                   }
22                   cout<<res<<endl;
23              }
24           return 0;
25     }

B 题目 神题   没想到  结果是   无论如何走   都可以 使得答案  <= 500; 因为  一旦选择 A 进行+ 运算  超过 500 这时就放弃选择A而选择用 B 减去得到的结果;

 1 #include<iostream>
 2 #include<stdio.h>
 3 #include<cstring>
 4 #include<algorithm>
 5 using namespace std;
 6 
 7 int a[1000006],b[1000006];
 8 
 9 int main( )
10 {
11    int i,N,res;
12    while( scanf("%d",&N) != EOF )
13    {               
14         res = 0;
15         for( i = 1; i <= N; i++ )
16            scanf("%d%d",&a[i],&b[i]);
17         for( i = 1; i <= N; i++ )
18         if( res + a[i] >= 500 )
19         {
20            res -= b[i],printf("G");
21         }
22         else 
23         {
24            res += a[i],printf("A");
25         }
26            cout<<endl;
27    }
28    return 0;
29 }

C题  一开始 一个观点错误  以为  0^0 == 1  发现错了之后  就 A 了   如果存在  10  那么这个  10 可以 变成 11 然后变成 01 所以可以给每一位都变成至少一个  1 的状态;那么这个 10 就可以  经过变换转换到边边上,然后从左到右   依次变换;得到想要的 01串,但  01 状态  无法变成  00 状态  而  00 状态 也无法变成 10 状态  所以特判这两种状态  就行了

 1 #include<iostream>
 2 #include<cstring>
 3 #include<algorithm>
 4 #include<stdio.h>
 5 using namespace std;
 6 
 7 char str[1234567],cha[1234567];
 8 
 9 int main( )
10 {
11     while( scanf("%s%s",&str,&cha) != EOF )
12     {
13         int len1 = strlen( str );
14         int len2 = strlen( cha );
15         int res1 = 0,res2 = 0;
16         if( len1 != len2 ) 
17         {
18             printf("NO\n");
19             continue;
20         }
21         for( int i = 0; i < len1; i++ )
22         {
23             if( str[i] == '1' )res1++;
24             if( cha[i] == '1' )res2++;
25         }
26         if( ( res1 == 0 && res2 ) || ( res1 && res2 == 0 ) )
27              printf("NO\n");
28         else printf("YES\n");
29     }
30     return 0;
31 }

D题  博弈论   博弈  先去看看文章  再做题吧! 考虑  N == 3 时  为什么会是 Nim 博弈呢!因为根据定义 发现   N N N

这是一个必胜利状态;可以变成  必败状态  0 0 0;而一个  必败状态  比如说  x y z  同时取走  t 个时  平衡破坏;还是可以通过改变 x y z 中的值  来使得  x ^y^z  =  0  不知道对不对;~~

 1 #include<iostream>
 2 #include<stdio.h>
 3 #include<cstring>
 4 #include<algorithm>
 5 #include<cmath>
 6 using namespace std;
 7 
 8 int main( )
 9 {
10     int N,a,b,c;
11     while( scanf("%d",&N) != EOF )
12     {
13         scanf("%d",&a);
14         if( N == 1 ) 
15         {
16             if( a ) printf("BitLGM\n");
17             else    printf("BitAryo\n");
18             continue;
19         }
20         scanf("%d",&b);
21         if( a > b ) swap( a,b );
22         if( N == 2 )
23         {
24             if( int((b-a)*(1+sqrt(5))/2.0) == a ) printf("BitAryo\n");
25             else                                  printf("BitLGM\n");
26             continue;
27         }
28         scanf("%d",&c);
29         if( N == 3 )
30         {
31             if( (a^b^c) == 0 )  printf("BitAryo\n");
32             else                printf("BitLGM\n");
33         } 
34     }
35     return 0;
36 }

 

 E题  这题 真是让我长见识了  哈哈  好题啊   tree 树 还能这么用;

 1 #include<iostream>
 2 #include<stdio.h>
 3 #include<cstring>
 4 #include<algorithm>
 5 using namespace std;
 6 
 7 struct tree
 8 {
 9     tree *son[2];
10     long long val;
11 }*root;
12 long long arr[112345],res,ans;
13 int cnt[49];
14 
15 tree *Creat_node( )
16 {
17     tree *temp = new tree;
18           temp->son[0] = NULL;
19           temp->son[1] = NULL;
20           temp->val    = 0;
21    return temp;
22 }
23 
24 void Insert( long long num )
25 {
26     long long k = 0;
27     memset( cnt,0,sizeof(cnt) );
28     for( int i = 0; i <= 44; i++ )
29     cnt[i] = 1&(num>>i);
30     tree *temp = root;
31     for( int i = 44; i >= 0; i-- )
32     {
33         if( temp->son[cnt[i]] == NULL )
34             temp->son[cnt[i]] =  Creat_node();
35             temp = temp->son[cnt[i]];
36     }
37             temp->val = num;
38 }
39 long long Query( long long num )
40 {
41     long long k = 0;
42     memset( cnt,0,sizeof(cnt) );
43     for( int i = 0; i <= 44; i++ )
44     cnt[i] =1&(num>>i);
45     tree *temp = root;
46     for( int i = 44; i >= 0; i-- )
47     {
48         if(  temp->son[0] == NULL )
49               temp = temp->son[1];
50         else if( temp->son[1] == NULL )
51                 temp = temp->son[0];
52              else if( cnt[i] )
53                       temp = temp->son[0];
54                      else temp = temp->son[1];
55     }
56     return num^(temp->val);
57 }
58 int main( )
59 {
60     int N;
61     while( scanf("%d",&N) != EOF )
62     {
63         root = Creat_node();
64          res = 0,ans = 0;
65         for( int i = 1; i <= N; i++ )
66         {
67             scanf("%I64d",&arr[i]);
68             ans^=arr[i];
69             Insert( ans );
70             res = max( res,ans );
71         }
72         ans = 0;
73         Insert(0);
74         for( int i = N; i >= 1; i-- )
75         {
76            ans ^= arr[i];
77            res = max( res,Query(ans) );
78         }
79         printf("%I64d\n",res);
80     }
81     return 0;
82 }

 

转载于:https://www.cnblogs.com/wulangzhou/archive/2013/03/20/2971991.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值