Codeforces Round #124 (Div. 2)

A. Plate Game

题意:给出桌子大小,和圆盘的半径,两个人轮流放盘子,盘子不可以重叠,谁先没有地方放盘子,那么这个人就输了。

这题尼玛坑爹啊。。。神题+群里大牛神解。。跪了。

只要第一个人可以放下盘子,那么他肯定是能赢的,First能放的话就放中间,随便第二个人怎么下,以中心为对称点模仿他就行了。

#include<iostream>
#include<cstdio>
using namespace std;
int main() {
    int a , b , r;
    while(scanf("%d%d%d",&a,&b,&r)!=EOF) {
        if(2*r > a || 2*r > b) printf("Second\n");
        else printf("First\n");    
    }    
}

B. Limit

题意:就是两个多项式相比,求极限。

学过高数,基本就可以A了。

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int gcd(int a , int b) {
        return b == 0 ? a : gcd(b , a%b);
}
int main() {
    int n , m , i , a , b;
    while(scanf("%d%d",&n,&m)!=EOF) {
        int maxa = 0;
        int maxb = 0;
        scanf("%d",&maxa);
        for(i = 1 ; i <=n ; i ++) {
            scanf("%d",&a);    
        }        
        scanf("%d",&maxb);
        for(i = 1 ; i <= m ; i ++) {
            scanf("%d",&b);    
        }
        if(n > m) {
            if(maxa*maxb > 0) {
                printf("Infinity\n");
                continue;    
            } else if(maxa*maxb < 0) {
                printf("-Infinity\n");
                continue;    
            }    
        } else if(n < m) {
            printf("0/1\n");
            continue;    
        } else {
            int lc = gcd(maxa , maxb);
            maxa = maxa/lc;
            maxb = maxb/lc;
            if(maxa*maxb>0) {
                printf("%d/%d\n",maxa,maxb);
                continue;    
            } else if(maxa*maxb<0) {
                printf("-%d/%d\n",abs(maxa),abs(maxb));
                continue;    
            }
        }
    }    
}

C. Lexicographically Maximum Subsequence

题意:从前往后找字典序大的序列,看给出的case比较容易懂。

思路:我是先扫一遍字符串,记录下每个字母出现的次数,然后找出字典序最大的那个字母,再从前往后扫一遍字符串,如果这个字母是当前找的字典序最大的字母(标记是k),那么就输出这个字母,同时这个字母出现的次数减一,否则不输出,但是字母出现的次数也减一。如果当前字典序最大的字母已经找完了,那么找出除此字母外最大的字母,重复这些操作。

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main() {
    char str[100100];
    int cnt[30];
    int i , j , k , h;
    char c;
    while(scanf("%s",str)!=EOF) {
        int len = strlen(str);
        c = 'a' - 10;
        j = 0;
        memset(cnt , 0 , sizeof(cnt));
        for (i = 0 ; i < len ; i ++) {
            cnt[str[i]-'a'] ++;        
        }
        for(i = 27 ; i >= 0 ; i --) {
            if(cnt[i] > 0) {
                k = i;break;    
            }        
        }
        for (i = 0 ; i < len ; i ++) {
            if(k==(str[i]-'a')) {
                cnt[str[i]-'a']--;
                printf("%c",str[i]);    
            }
            else cnt[str[i]-'a'] --;
            if(cnt[k]==0) {
                for(h = k ; h >=0 ; h --) {
                    if(cnt[h] > 0) {
                        k = h;
                        break;    
                    }   
                }
            }
        }
        printf("\n");
    }    
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值