UVa12700 - Banglawash(杂题)
来源:互联网 发布:折装导轮的工具的数据 编辑:程序博客网 时间:2024/05/18 17:43
import java.io.FileInputStream;import java.io.BufferedReader;import java.io.InputStreamReader;import java.io.PrintWriter;import java.io.OutputStreamWriter;import java.io.StreamTokenizer;public class Main {private static final boolean DEBUG = false;private BufferedReader cin;private PrintWriter cout;private StreamTokenizer tokenizer;private int n;private String s;public void init() {try {if (DEBUG) {cin = new BufferedReader(new InputStreamReader(new FileInputStream("e:\\uva_in.txt")));} else {cin = new BufferedReader(new InputStreamReader(System.in));}tokenizer = new StreamTokenizer(cin);cout = new PrintWriter(new OutputStreamWriter(System.out));} catch (Exception e) {e.printStackTrace();}}private String next() {try { tokenizer.nextToken(); if (tokenizer.ttype == StreamTokenizer.TT_EOF) return null; else if (tokenizer.ttype == StreamTokenizer.TT_NUMBER) { return String.valueOf((int)tokenizer.nval); } else return tokenizer.sval;} catch (Exception e) {e.printStackTrace();return null;}}public boolean input() {n = Integer.parseInt(next());s = next();return true;}public void solve(int cas) {int[] cnt = new int[4];for (int i = 0, size = s.length(); i < size; i++) {char ch = s.charAt(i);if (ch == 'B') cnt[0]++;else if (ch == 'W') cnt[1]++;else if (ch == 'T') cnt[2]++;else if (ch == 'A') cnt[3]++;}//if (cas != 1) cout.print(" ");cout.print("Case " + cas + ": ");if (cnt[0] != 0 && cnt[0] + cnt[3] == n) cout.println("BANGLAWASH");else if (cnt[1] != 0 && cnt[1] + cnt[3] == n) cout.println("WHITEWASH");else if (cnt[3] == n) cout.println("ABANDONED");else if (cnt[0] > cnt[1]) cout.println("BANGLADESH " + cnt[0] + " - " + cnt[1]);else if (cnt[0] < cnt[1]) cout.println("WWW " + cnt[1] + " - " + cnt[0]);else cout.println("DRAW " + cnt[0] + " " + cnt[2]);cout.flush();}public static void main(String[] args) {Main solver = new Main();solver.init();int t = Integer.parseInt(solver.next());for (int i = 1; i <= t; i++) {solver.input();solver.solve(i);}}}
0 0
- UVa12700 - Banglawash(杂题)
- UVa 12700 - Banglawash
- 杂题
- 杂题
- XP 杂题
- 【杂题】fish
- 杂题-01
- [杂题]AGC015C
- [ 杂题 ] BZOJ5085
- [杂题] pku 2019
- POJ 3299 Humidex 杂题
- POJ杂题(水杂)
- 【杂题】HDOJ 4768 Flyer
- poj 杂题 - 1959 Darts
- 杂题 - hdu5357 Easy Sequence
- HDU 5233 杂题
- HDU 5480 杂题
- 第一层内容:杂题
- Objective-C 基础,类和对象,方法和消息,已声明的属性和存取方法,块对象,协议和范畴类,预定义类型和编码策略
- s p i C R C DMA
- SpringMVC学习(一)--框架搭建
- Oracle学习日志之sequence创建ID自增功能
- SRM 626 D1L2:CatchTheBeat,Longest increasing subsequence,O(NlogN) 算法
- UVa12700 - Banglawash(杂题)
- C语言getopt()函数的使用及参数
- css border颜色显示不一致
- 深入理解HashMap
- JAX-RS入门 三 :细节
- 模板引擎介绍
- boost::shared_ptr使用技巧
- String to Integer (atoi)
- SEO的核心:我们是在为用户做优化