Educational Codeforces Round 26总结

A. Text Volume
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a text of single-space separated words, consisting of small and capital Latin letters.

Volume of the word is number of capital letters in the word. Volume of the text is maximum volume of all words in the text.

Calculate the volume of the given text.

Input

The first line contains one integer number n (1 ≤ n ≤ 200) — length of the text.

The second line contains text of single-space separated words s1, s2, ..., si, consisting only of small and capital Latin letters.

Output

Print one integer number — volume of text.

Examples
input
7
NonZERO
output
5
input
24
this is zero answer text
output
0
input
24
Harbour Space University
output
1
Note

In the first example there is only one word, there are 5 capital letters in it.

In the second example all of the words contain 0 capital letters.

题意:问这些单词中最多有多少个大写字母
import java.util.Scanner;

/**
 * 
 * 作者:张宇翔
 * 创建日期:2017年8月3日 下午10:54:33
 * 描述:永远的ACM
 */
public class Main {
	private static final int Max=(int) (1e6+10);
	private static int n;
	private static String s;
	public static void main(String[] args) {
		InitData();
		GetAns();
	}

	private static void InitData() {
		Scanner cin=new Scanner(System.in);
		n=cin.nextInt();
		cin.nextLine();
		s=cin.nextLine();
	};
	private static void GetAns(){
		String []split=s.split(" ");
		
		int ans=Integer.MIN_VALUE;
		for(int i=0;i='A'&&split[i].charAt(j)<='Z'){
					cnt++;
				}
			}
			ans=Math.max(ans, cnt);
//			System.out.println(split[i]);
		}
		System.out.println(ans);
	}
	
}
B. Flag of Berland
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The flag of Berland is such rectangular field n × m that satisfies following conditions:

  • Flag consists of three colors which correspond to letters 'R''G' and 'B'.
  • Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
  • Each color should be used in exactly one stripe.

You are given a field n × m, consisting of characters 'R''G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).

Input

The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field.

Each of the following n lines consisting of m characters 'R''G' and 'B' — the description of the field.

Output

Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).

Examples
input
6 5
RRRRR
RRRRR
BBBBB
BBBBB
GGGGG
GGGGG
output
YES
input
4 3
BRG
BRG
BRG
BRG
output
YES
input
6 7
RRRGGGG
RRRGGGG
RRRGGGG
RRRBBBB
RRRBBBB
RRRBBBB
output
NO
input
4 4
RRRR
RRRR
BBBB
GGGG
output
NO
Note

The field in the third example doesn't have three parralel stripes.

Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 21 and 1.

题意:能不能将面积为n*m的区域划分成3个,并且3个颜色不同(每个区域颜色相同)
解:简单模拟
import java.util.Scanner;

/**
 * 
 * 作者:张宇翔
 * 创建日期:2017年8月3日 下午10:54:33
 * 描述:永远的ACM
 */
public class Main {
	private static final int Max=(int) (1e3+10);
	private static int n,m;
	private static String s[];
	public static void main(String[] args) {
		InitData();
		GetAns();
	}

	private static void InitData() {
		Scanner cin=new Scanner(System.in);
		s=new String[Max];
		n=cin.nextInt();
		m=cin.nextInt();
		for(int i=0;i


C. Two Seals
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

One very important person has a piece of paper in the form of a rectangle a × b.

Also, he has n seals. Each seal leaves an impression on the paper in the form of a rectangle of the size xi × yi. Each impression must be parallel to the sides of the piece of paper (but seal can be rotated by 90 degrees).

A very important person wants to choose two different seals and put them two impressions. Each of the selected seals puts exactly one impression. Impressions should not overlap (but they can touch sides), and the total area occupied by them should be the largest possible. What is the largest area that can be occupied by two seals?

Input

The first line contains three integer numbers na and b (1 ≤ n, a, b ≤ 100).

Each of the next n lines contain two numbers xiyi (1 ≤ xi, yi ≤ 100).

Output

Print the largest total area that can be occupied by two seals. If you can not select two seals, print 0.

Examples
input
2 2 2
1 2
2 1
output
4
input
4 10 9
2 3
1 1
5 10
9 11
output
56
input
3 10 10
6 6
7 7
20 5
output
0
Note

In the first example you can rotate the second seal by 90 degrees. Then put impression of it right under the impression of the first seal. This will occupy all the piece of paper.

In the second example you can't choose the last seal because it doesn't fit. By choosing the first and the third seals you occupy the largest area.

In the third example there is no such pair of seals that they both can fit on a piece of paper.


题意:选择两个(必须)章,使其占有的面积最大,并且不能覆盖(不能选两个输出0),可以旋转90度
解:将第一个放在左上角,然后看剩余的区域能不能放下第二个
import java.util.Scanner;

/**
 * 
 * 作者:张宇翔
 * 创建日期:2017年8月3日 下午10:54:33
 * 描述:永远的ACM
 */
public class Main {
	private static final int Max=(int) (1e3+10);
	private static int n,a,b;
	private static int []x;
	private static int []y;
	public static void main(String[] args) {
		InitData();
		GetAns();
	}

	private static void InitData() {
		Scanner cin=new Scanner(System.in);
		x=new int[Max];
		y=new int[Max];
		n=cin.nextInt();
		a=cin.nextInt();
		b=cin.nextInt();
		for(int i=0;i


D. Round Subset
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Let's call the roundness of the number the number of zeros to which it ends.

You have an array of n numbers. You need to choose a subset of exactly k numbers so that the roundness of the product of the selected numbers will be maximum possible.

Input

The first line contains two integer numbers n and k (1 ≤ n ≤ 200, 1 ≤ k ≤ n).

The second line contains n space-separated integer numbers a1, a2, ..., an (1 ≤ ai ≤ 1018).

Output

Print maximal roundness of product of the chosen subset of length k.

Examples
input
3 2
50 4 20
output
3
input
5 3
15 16 3 25 9
output
3
input
3 3
9 77 13
output
0
Note

In the first example there are 3 subsets of 2 numbers. [50, 4] has product 200 with roundness 2[4, 20] — product 80roundness 1,[50, 20] — product 1000roundness 3.

In the second example subset [15, 16, 25] has product 6000roundness 3.

In the third example all subsets has product with roundness 0.


题意:从n个数中选k个数,使这K个数的乘积末尾的0个数最多
写的太复杂了,直接看代码吧
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

/**
 * 
 * 作者:张宇翔
 * 创建日期:2017年8月3日 下午10:54:33
 * 描述:永远的ACM
 */
public class Main {
	private static final int Max=(int) (1e3+10);
	private static int n,k;
	private static ArrayList list2;
	private static ArrayList list5;
	private static ArrayList list25;
	
	public static void main(String[] args) {
		InitData();
		GetAns();
	}

	private static void InitData() {
		Scanner cin=new Scanner(System.in);
		list2=new ArrayList<>();
		list5=new ArrayList<>();
		list25=new ArrayList<>();
		n=cin.nextInt();
		k=cin.nextInt();
		long a;
		for(int i=0;i() {

			@Override
			public int compare(Node25 o1, Node25 o2) {
				return Math.min(o1.con2, o1.con5)-Math.min(o2.con2, o2.con5);
			}
		});
		Collections.sort(list2,new Comparator() {

			@Override
			public int compare(Node2 o1, Node2 o2) {
				return o1.con2-o2.con2;
			}
		});
		Collections.sort(list5,new Comparator() {

			@Override
			public int compare(Node5 o1, Node5 o2) {
				return o1.con5-o2.con5;
			}
		});
		
		
		int cnt=0;
		int ANS2=0,ANS5=0;
		int len2=list2.size()-1;
		int len5=list5.size()-1;
		int len25=list25.size()-1;
		
		while(cnt=0||len5>=0||len25>=0)){
			int ans1=-1,ans2=-1,ans3=-1;
			if(len25>=0){
				ans1=Math.min(list25.get(len25).con2, list25.get(len25).con5);
			}
			if(len2>=0){
				ans2=list2.get(len2).con2;
			}
			if(len5>=0){
				ans3=list5.get(len5).con5;
			}
			if(cnt==k-1){
//				if(ans1!=-1){
//					ANS2+=list25.get(len25).con2;
//					ANS5+=list25.get(len25).con5;
//				}else{
//					if(ans2!=-1&&ans3!=-1){
//						if(Math.min(ANS2+ans2, ANS5)>=Math.min(ANS2, ANS5+ans3)){
//							ANS2+=ans2;
//						}else{
//							ANS5+=ans3;
//						}
//					}else if(ans2!=-1&&ans3==-1){
//						ANS2+=ans2;
//					}else{
//						ANS5+=ans3;
//					}
//				}
				
				if(ans1!=-1&&ans2!=-1&&ans3!=-1){//!!!
					int k1=Math.min(ANS2+list25.get(len25).con2, ANS5+list25.get(len25).con5);
					int k2=Math.min(ANS2+ans2, ANS5);
					int k3=Math.min(ANS2, ANS5+ans3);
					int k=Math.max(k1, Math.max(k2, k3));
					if(k==k1){
						ANS2+=list25.get(len25).con2;
						ANS5+=list25.get(len25).con5;
					}else if(k==k2){
						ANS2+=ans2;
					}else{
						ANS5+=ans3;
					}
				}else if(ans1!=-1&&ans2!=-1&&ans3==-1){//!!=
					int k1=Math.min(ANS2+list25.get(len25).con2, ANS5+list25.get(len25).con5);
					int k2=Math.min(ANS2+ans2, ANS5);
					int k=Math.max(k1, k2);
					if(k==k1){
						ANS2+=list25.get(len25).con2;
						ANS5+=list25.get(len25).con5;
					}else{
						ANS2+=ans2;
					}
				}else if(ans1!=-1&&ans2==-1&&ans3!=-1){//!=!
					int k1=Math.min(ANS2+list25.get(len25).con2, ANS5+list25.get(len25).con5);
					int k2=Math.min(ANS2, ANS5+ans3);
					int k=Math.max(k1, k2);
					if(k==k1){
						ANS2+=list25.get(len25).con2;
						ANS5+=list25.get(len25).con5;
					}else{
						ANS5+=ans3;
					}
				}else if(ans1!=-1&&ans2==-1&&ans3==-1){//!==
					ANS2+=list25.get(len25).con2;
					ANS5+=list25.get(len25).con5;
				}else if(ans1==-1&&ans2!=-1&&ans3!=-1){//=!!
					int k2=Math.min(ANS2+ans2, ANS5);
					int k3=Math.min(ANS2, ANS5+ans3);
					int k=Math.max(k2, k3);
					if(k==k2){
						ANS2+=ans2;
					}else{
						ANS5+=ans3;
					}
				}else if(ans1==-1&&ans2!=-1&&ans3==-1){//=!=
					ANS2+=ans2;
				}else if(ans1==-1&&ans2==-1&&ans3!=-1){//==!
					ANS5+=ans3;
				}else if(ans1==-1&&ans2==-1&&ans3==-1){//===
					continue;
				}
				break;
			}
			if(ans1>=Math.min(ans2, ans3)&&ans1!=-1){
				ANS2+=list25.get(len25).con2;
				ANS5+=list25.get(len25).con5;
				len25--;
				cnt++;
			}else{
				if(ans2!=-1&&ans3!=-1){
					ANS2+=ans2;
					ANS5+=ans3;
				}else if(ans2!=-1&&ans3==-1){
					ANS2+=ans2;
				}else{
					ANS5+=ans3;
				}
				len2--;
				len5--;
				cnt+=2;
			}
		}
//		System.out.println(ANS2+"  "+ANS5);
		System.out.println(Math.min(ANS2, ANS5));
	}
	
	
	private static void Get(long x){
		int ans2=0,ans5=0;
		while(x%2==0){
			ans2++;
			x/=2;
		}
		while(x%5==0){
			ans5++;
			x/=5;
		}
		if(ans2!=0&&ans5!=0){
			Node25 node25=new Node25(ans2, ans5);
			list25.add(node25);
		}else if(ans2!=0&&ans5==0){
			Node2 node2=new Node2(ans2);
			list2.add(node2);
		}else{
			Node5 node5=new Node5(ans5);
			list5.add(node5);
		}
	}
	
	static class Node2{
		int con2;
		public Node2(int con2) {
			this.con2 = con2;
		}
	}
	static class Node5{
		int con5;
		public Node5(int con5) {
			this.con5 = con5;
		}
	}
	static class Node25{
		int con2;
		int con5;
		public Node25(int con2, int con5) {
			this.con2 = con2;
			this.con5 = con5;
		}
	}
	
}



你可能感兴趣的:(ACM,CoderForce)