A. The Child and Homework

http://codeforces.com/contest/437/problem/A

 1 import java.util.ArrayList;
 2 import java.util.Scanner;
 3
 4 public class Main {
 5
 6     public static void main(String[] args) {
 7         Scanner in = new Scanner(System.in);
 8         while (in.hasNext()){
 9             int[]len=new int[4];
10             int[]min=new int[4];
11             int[]max=new int[4];
12             for (int i = 0; i < 4; i++) {
13                 String s=in.nextLine();
14                 while (s.length()==0)s=in.nextLine();
15                 len[i]=s.length()-2;
16             }
17             for (int i = 0; i < 4; i++) {
18                 for (int j = 0; j < 4; j++) {
19                     if (j==i)continue;
20                     if (len[j]>=len[i]*2)min[i]++;
21                     if (len[j]*2<=len[i])max[i]++;
22                 }
23             }
24             ArrayList<Integer>al=new ArrayList<>();
25             for (int i = 0; i < 4; i++) if (min[i]==3||max[i]==3)al.add(i);
26             if (al.size()!=1) System.out.println("C");
27             else System.out.println((char)(al.get(0)+‘A‘));
28         }
29     }
30 }

原文地址:https://www.cnblogs.com/towerbird/p/11404606.html

时间: 2024-10-24 09:27:04

A. The Child and Homework的相关文章

codeforces --- Round #250 (Div. 2) A. The Child and Homework

<传送门> 这题就是一个坑,尼玛wa了一大片啊. 自己被hack了,比赛结束后改了又wa两次才过. [题目大意] 其实就是一个猜题小技巧(联系自己初中考试的时候怎么猜题的,这题就好理解多了).这位同学是这样来选答案的:1.如果有一些选项长度至少比其他所有的描述短两倍,或至少超过所有其他的描述的两倍,那么孩子认为这个选择很可能是正确的.2.如果正好满足以上其中一种条件(重点),这个同学就会选择它,否则就选C.给你一个选择题,让你选择出这个同学将会选择的答案. [题目分析] 首先,这个题目就是一个

xtu read problem training 3 A - The Child and Homework

The Child and Homework Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 437A64-bit integer IO format: %I64d      Java class name: (Any) Once upon a time a child got a test consisting of multiple-choice

大神刷题表

9月27日 后缀数组:[wikioi3160]最长公共子串 dp:NOIP2001统计单词个数 后缀自动机:[spoj1812]Longest Common Substring II [wikioi3160]最长公共子串 [spoj7258]Lexicographical Substring Search 扫描线+set:[poj2932]Coneology 扫描线+set+树上删边游戏:[FJOI2013]圆形游戏 结论:[bzoj3706][FJ2014集训]反色刷 最小环:[poj1734

COMP5048 Week 7 Homework

COMP5048 Week 7 Homework1. Dynamic graph visualisation with Gephi1. Open photoviz dynamic.gexf in Gephi. (Ignore any import errors)2. Click "Enable Timeline" below the graph display.3. Under “Appearance” tab on the left, select “Node” and select

HDU 1789 Doing Homework again(贪心)

Doing Homework again Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in the homework after the deadlin

uva 1489 - Math teacher&#39;s homework(数位dp)

题目链接:uva 1489 - Math teacher's homework 题目大意:给定n,k,以及序列m1,m2,-,mn, 要求找到一个长度为n的序列,满足0<=xi<=mi, 并且x1XORx2XOR-XORxn=k 解题思路:数位dp,在网上看了别人的代码,高大上... 假设有二进制数 k : 00001xxxx mi:0001xxxxx, 那么对于xi即可以满足任意的x1XORx2XOR-XORxi?1XORxi+1XOR-XORxn,根据这一点进行数位dp. dp[i][j]

加压压缩文件报错gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now

压缩包是直接weget 后面加官网上的tar包地址获取的 [[email protected] ~]# tar -zxvf /home/hadoop/hadoop-2.6.5-src.tar.gz gzip: stdin: not in gzip formattar: Child returned status 1tar: Error is not recoverable: exiting now[[email protected] ~]# tar -xvf /home/hadoop/hadoo

out of memory kill process (java) score or a child

最近在跑大数据,发现 out of memory kill process (java) score or a child,查资料发现是操作系统linux low mem 太低,后来加大内存一样不管用,开始分析代码: 将代码中的String 字符串拼接改成StringBuilder(单线程速度比StringBuffer快) 将获取文件名称的方法file.listFiles() 改成 file.list() 将代码中的不必要的创建对象.数组开销去掉,尤其是在循环里 发现仍然有问题,通过free -

LINUX:解压问题tar: Child returned status

解压某个文件时 #tar -zxvf xxxxx.tar.gz 出现下面的错误提示: gzip: stdin: not in gzip formattar: Child returned status 1tar: Error exit delayed from previous errors You used "tar -zxvf" for the second command. the 'z' option tells tar to use gzip to uncompress th