博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
华中农业大学校赛--c The Same Color
阅读量:4977 次
发布时间:2019-06-12

本文共 2469 字,大约阅读时间需要 8 分钟。

Problem C: The Same Color

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 993  Solved: 595
[][][]

Description

 

   Diao Yang has many balls with different colors. Today he wants to divide his balls into two groups. But he does not know how to divide. Then Diao Ze gives him a suggestion: first you choose a ball and put it into the first group. Then from the second ball, if the color of the ball is same to the last ball you has chosen, then you put the ball into the other group. Otherwise you put the ball into the same group with the last ball. Diao Yang thinks it is OK.

 

   Then the problem is, Diao Yang wants to know the product of the number of two groups’ balls. Can you help him?

Input

 

   The first line contains an integer T, indicating the number of test cases.

   In each test case, there are several lines, each line contains only one string with lowercas, indicating the color of the ball Diao Yang has chosen currently. Diao Yang will stop choosing when the string is equal to “END”. Note that the string “END” does not mean a color.

   You can assume that there are at most 100 lines in each test case and each string has at most 10 letters.

 

Output

 

   For each test case, output the answer in a line.

Sample Input

3yellowyellowpinkredredgreenENDblueblackpurplepurpleENDroseorangebrownwhiteEND

Sample Output

930

HINT

 

 

 

In the first test case, the color of the first group’s balls are yellow, red, green, 3 balls in total. The color of the second group’s balls are yellow, pink, red, 3 balls in total too. So the product is 3×3=9.

   In the second test case, the answer is 3×1=3 and in the third test case the answer is 4×0=0.

 

 

#include
#include
#include
#include
using namespace std;int main(){ int n; scanf("%d",&n); while(n--) { int g[2]; g[0]=1; g[1]=0; char a[12]; char b[12]; scanf("%s",b); int t=0; if(strcmp(b,"END")==0) { printf("0\n"); continue; } scanf("%s",a); while(strcmp(a,"END")!=0) { if(strcmp(a,b)==0) { t=1-t; g[t]++; } else { g[t]++; } strcpy(b,a); scanf("%s",a); } printf("%d\n",g[0]*g[1]); } return 0;}
View Code

水题,只是考虑第一个颜色就是END就可以了。wa惨了

转载于:https://www.cnblogs.com/superxuezhazha/p/5496089.html

你可能感兴趣的文章
SpringMVC------在运行项目的时候run as 里面没有run on server 解决办法
查看>>
Win10+Anaconda3+Eclipse+Django+MySQL 配置Python的Web开发环境
查看>>
类方法使用
查看>>
Get Luffy Out poj 2723 Tarjan+2-SAT
查看>>
Wild Number (Standard IO)
查看>>
在Visual Studio 2005中调试SQL Server 2005的存储过程
查看>>
浅析C#基于TCP协议的SCOKET通信
查看>>
文件资源使用Texture管理cocosBuilder项目资源:纹理文件使用(TexturePacker)
查看>>
Java Web应用CAS Client端的配置详解
查看>>
MapGIS计算瓦片数据集
查看>>
你最美好的年华
查看>>
中兴MF667S WCDMA猫Linux拨号笔记
查看>>
jQuery
查看>>
探究绑定事件的this指向以及event传参的小问题
查看>>
BOM window对象 localtion navigator
查看>>
Linux的.pid文件
查看>>
unity性能优化-CPU
查看>>
使用ssh正向连接、反向连接、做socks代理的方法
查看>>
IOS AppStore介绍图的尺寸大小(还有一些自己被拒的分享...)
查看>>
Android 实现在线程中联网
查看>>