读书人

【2013春季SD大学ACM周赛8(SDUT)】各

发布时间: 2013-03-12 11:19:35 作者: rapoo

【2013春季SD高校ACM周赛8(SDUT)】各水题题解

今天下午状态不错,4A。。主要是比较简单。。做出来的中只有一道题不算水题吧。。

比赛地址:点击打开链接

Problem A:Mad Scientist

很水的一道题,读题略微坑人,明白了就好。从一种表示方法转移到另一种表示方法。第一个数表示样例,第二个数K表示小于等于K的总数有几个,数的值等于它下标所在的位置(从1开始)。

#include <iostream>#include <string>#include <stdlib.h>#include <cmath>using namespace std;int main(){string tar;while(cin>>tar && tar!="#"){int totalpeople=tar.size();double halfman=totalpeople/2.0;int yesvote=0;int novote=0;int absent=0;for(int i=0;i<tar.size();i++){if(tar[i]=='Y')yesvote+=1;else if(tar[i]=='N')novote+=1;else if(tar[i]=='A')absent+=1;}if(totalpeople-absent>halfman){if(yesvote>novote)cout<<"yes"<<endl;else if(novote>yesvote)cout<<"no"<<endl;elsecout<<"tie"<<endl;}else{cout<<"need quorum"<<endl;}}return 0;}



读书人网 >编程

热点推荐