codeforces——模拟

805 B. 3-palindrome    http://codeforces.com/problemset/problem/805/B

/*
题意字符串中不能有长度为三的回文串,且c数量最少
*/
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;
char s[4]={'a','a','b','b'};
int n;

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
      printf("%c",s[i%4]);
    printf("\n");
    return 0;
}
View Code

807 A Is it rated?       http://codeforces.com/problemset/problem/807/A

#include<iostream>
#include<cstdio>
#include<cstring>

#define maxn 1001

using namespace std;

int n,m,cnt;
int a[maxn],b[maxn];

inline int init()
{
    int x=0,f=1;char c=getchar();
    while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

int main()
{
    n=init();
    for(int i=1;i<=n;i++)
    {
        a[i]=init();b[i]=init();
    }
    for(int i=2;i<=n;i++)
    {
        if(a[i]!=b[i])
        {
            printf("rated\n");
            return 0;
        }
        if(a[i]>a[i-1])
        {
            printf("unrated\n");
            return 0;
        }
    }
    printf("maybe\n");
    return 0;
}
View Code

错误代码

#include<iostream>
#include<cstdio>
#include<cstring>

#define maxn 1001

using namespace std;

int n,m,cnt;
int a[maxn],b[maxn];

inline int init()
{
    int x=0,f=1;char c=getchar();
    while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

int main()
{
    n=init();
    for(int i=1;i<=n;i++)
    {
        a[i]=init();b[i]=init();
    }
    for(int i=2;i<=n;i++)
    {
        if(a[i]!=b[i])//这里!!可能第一个就不相同
        {
            printf("rated\n");
            return 0;
        }
        if(a[i]>a[i-1])
        {
            printf("unrated\n");
            return 0;
        }
    }
    printf("maybe\n");
    return 0;
}
View Code

 

posted @ 2017-05-14 20:22  安月冷  阅读(413)  评论(0编辑  收藏  举报