zoukankan      html  css  js  c++  java
  • 解题报告CF266B 384A 339A

    最近状态很差,闲着没事,做了三个水题,好久没看博客了,还是把水题解题报告写写吧,唉。。话说都这么久了,读题还经常读错。。

    384A 题目链接  http://codeforces.com/problemset/problem/384/A

    题目的意思就是输入一个数,给出一个n*n的矩形,让每两个C不可以横竖相连。

    那就很简单了,找下规律可以看出来对于偶数是n*n/2,对于奇数是n*n/2+1;然后根据奇偶来判断画图就ok,直接贴代码,很简单。

    //by hust_archer
    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<algorithm>
    using namespace std;

    int main()
    {
    int n,i,j;
    scanf("%d",&n);
    printf("%d ",(n*n)/2+n%2);
    for(i=1;i<=n;i++)
    {
    for(j=1;j<=n;j++)
    {
    if(i%2 == 1&&j%2==1||i%2==0&&j%2==0)
    {
    printf("C");
    }
    else
    {
    printf(".");
    }
    }
    printf(" ");
    }

    return 0;
    }

    CF266B

    题目链接:http://codeforces.com/problemset/problem/266/B

    题目大意,G代表女孩,B代表男孩给女孩让队,输入几个让几个,根据题目给的规矩来交换位置。

    水题,直接模拟。

    //by hust_archer
    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<algorithm>
    using namespace std;

    int main()
    {
    int n,t,i,j;
    int length;
    char str[55];
    scanf("%d %d",&n,&t); //字符数组存,那个n没用到
    scanf("%s",&str);
    length=strlen(str);//length即为字符串长度,这样遍历就ok了
    for(i=0;i<t;i++)
    {
    for(j=0;j<length-1;j++)
    {
    if(str[j]=='B'&&str[j+1]=='G')  //判断以后交换
    {
    str[j]='G';
    str[j+1]='B';
    j++;
    }
    }
    }

    printf("%s ",str);
    return 0;
    }

    CF339A 题目链接:http://codeforces.com/problemset/problem/339/A

    大意:排序以后,换位置即可。

    从小到大排序

    这题也是字符串摸拟,搞两个数组一个存字符串,一个存数字,数字排个序,最后输出的时候,带个加号就ok

    代码:

    //by hust_archer
    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<algorithm>
    using namespace std;
    char a[1000];
    int num[1005];
    int cnt=0;
    int main()
    {
    while(scanf("%s",&a)!=EOF)
    {
    int length=strlen(a);
    if(length==1)
    {
    printf("%s",a);
    continue;
    }
    for(int i=0;i<length;i++)
    {
    if(a[i]!='+')
    num[cnt++]=a[i]-'0'; //类型转换,字符串到int
    }
    sort(num,num+cnt);
    printf("%d",num[0]);
    for(int i=1;i<cnt;i++)
    {
    printf("+%d",num[i]);

    }
    printf(" ");
    }


    return 0;
    }

    做事情就要塌下心去做,最近太浮躁了。。

  • 相关阅读:
    Chrome cookies folder
    Fat URLs Client Identification
    User Login Client Identification
    Client IP Address Client Identification
    HTTP Headers Client Identification
    The Personal Touch Client Identification 个性化接触 客户识别
    购物车 cookie session
    购物车删除商品,总价变化 innerHTML = ''并没有删除节点,内容仍存在
    453
    购物车-删除单行商品-HTMLTableElement.deleteRow()
  • 原文地址:https://www.cnblogs.com/ruixingw/p/3657513.html
Copyright © 2011-2022 走看看