zoukankan      html  css  js  c++  java
  • RQNOJ PID51 / 乒乓球 ☆

    因为是多行输入,所以用了getchar()进行输入,题目没有说明数据范围,所以开始的时候因为数组开的不够大,WA90了一次,我之前开了10000的长度,之后开100000的长度跑过了

    一个基本的模拟,没什么套路

    #include<iostream>
    #include<algorithm>
    #include<cstdio>
    #include<cstring>
    #include<vector>
    using namespace std;
    int main()
    {
      int c;
      int W[100000],L[100000];
      int W2[100000],L2[100000];
      memset(W2,0,sizeof(W2));
      memset(L2,0,sizeof(L2));
      memset(W,0,sizeof(W));
      memset(L,0,sizeof(L));
      int count_r=0;
      int count_R=0;
      //int dou_w=0,dou_l=0,ele_w=0,ele_l=0;
      while((c=getchar())!=EOF)
      {
         if(c=='W')
         {
             W[count_r]++;
             W2[count_R]++;
         }
         if(c=='L')
         {
             L[count_r]++;
             L2[count_R]++;
         }
         if(W[count_r]>=11&&W[count_r]-L[count_r]>=2||L[count_r]>=11&&L[count_r]-W[count_r]>=2)
         {
             count_r++;
         }
         if(W2[count_R]>=21&&W2[count_R]-L2[count_R]>=2||L2[count_R]>=21&&L2[count_R]-W2[count_R]>=2)
         {
             count_R++;
         }
         if(c=='E')
         {
    
            for(int i=0;i<=count_r;i++)
            {
                cout<<W[i]<<":"<<L[i]<<endl;
            }
            cout<<endl;
            for(int i=0;i<=count_R;i++)
            {
                cout<<W2[i]<<":"<<L2[i]<<endl;
            }
            break;
         }
    
      }
        return 0;
    }
  • 相关阅读:
    es6-compact-table 名词备忘
    JS 防抖和节流函数
    为什么 JS 对象内部属性遍历的顺序乱了
    JS 发送 HTTP 请求方法封装
    JS 一些位操作的妙用
    JS 格式化时间
    linux ssh连接
    c# checked 和 unchecked
    c# mvc action 跳转方式
    IIS 动态与静态压缩
  • 原文地址:https://www.cnblogs.com/lulichuan/p/6496941.html
Copyright © 2011-2022 走看看