codeforce 173 div2 CF训练

A. Bit++

A题不说话,直接照着写就行了,不过傻逼了。开数组的时候就开了一个a[3],结果死活输不了第二组的数据。情急之下,直接上string。

#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int sum = 0;
    for(int i =0; i <n; ++i)
    {
        string s;
        cin >> s;
        if(s=="++X")
        sum++;
        else if(s=="X++")
        sum++;
        else if(s=="--X")
        sum--;
        else if(s=="X--")
        sum--;
    }
    cout << sum <<endl;
    return 0;
}

B. Painting Eggs

这道题木就是分钱,相当于。每拿到一对数,先给A,判断结果是不是符合abs(a-b)<500。符合的话就OK,不符合的话就把钱给G,就这样判断就可以了。代码:

#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
using namespace std;

int main()
{
    int n;
    int i;
    int a,b;
    cin >> n;
    int s1 = 0,s2 = 0;
    for(i = 1; i <= n; i++)
    {
        cin >> a >> b;
        s1 += a;
        if(s1-s2 >500 || s2-s1 >500)
        {
            cout << "G";
            s2 += b;
            s1 -= a;
        }
        else
            cout<<"A";
    }
    return 0;
}

C. XOR and OR

这道题目是1和0的异或和或的操作 。当然先判断两个字符串的长度是不是相同。不同就直接over了。再者就YY一下。判断两个字符串中是不是同时存在1.因为有1的话,我们可以转换我们需要的数字。如果两个字符串都是0的话,就直接OK就行了。代码:

#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
using namespace std;
char a[1000005];
char b[1000005];
int main()
{
    scanf("%s%s", a, b);
    int lena = strlen(a);
    int lenb = strlen(b);
    if(lena != lenb)
    {
        printf("NO\n");
        return 0;
    }
    int suma0 = 0, suma1 = 0, sumb0 = 0, sumb1 = 0;
    for(int i =0 ; i < lena; ++i)
    {
        if(a[i]=='1')
            suma1++;
        if(a[i]=='0')
            suma0++;
        if(b[i]=='0')
            sumb0++;
        if(b[i]=='1')
            sumb1++;
    }
    if((suma1 && sumb1) || suma1==sumb1)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


D. Yet Another Number Game

这道题目取三堆,分为堆数为1,为2,为3分析:是一堆的话就直接判断是不是0,不是就先手就赢了。两堆的时候就是威佐夫博弈,套公式啊。是三堆的话,考虑直接Nim博弈写的,这样是过了。就这样分情况分析,就行了。

#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
using namespace std;

int main()
{
    int n;
    int a, b, c;
    scanf("%d", &n);
    if(n==1)
    {
        cin >> a;
        if(a>0)
            printf("BitLGM\n");
        else
            printf("BitAryo\n");
    }
    else if(n==2)
    {
        cin >> a >> b;
        if(a==0 && b==0)
            printf("BitAryo\n");
        else
        {
            int mi = min(a, b);
            int mx = max(a, b);
            int k = ((mx-mi)*(sqrt(5.0)+1)/2);
            if(k==mi)
                printf("BitAryo\n");
            else
                printf("BitLGM\n");
        }
    }
    else if(n==3)
    {
        cin >> a >> b >> c;
        int sum = 0;
        sum ^= a;
        sum ^= b;
        sum ^= c;
        if(sum)
            printf("BitLGM\n");
        else
            printf("BitAryo\n");
    }
    return 0;
}


E. Sausage Maximization

额。。。E题貌似很神。还要看....

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值