Uva1339 Ancient Cipher

原创 2013年12月01日 23:55:28

题目链接:Uva1339 Ancient Cipher


水题一道,题目描述很复杂,其实只要统计句子中的单词数目是不是对应相等就好了。


import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		String enc_mess=new String();
		String ori_mess=new String();
		char[] enc_chars=null;
		char[] ori_chars=null;
		int[] alpha1=new int[26];
		int[] alpha2=new int[26];
		while(in.hasNext())
		{
			enc_mess=in.next();
			if(enc_mess.length()==0) break;
			enc_chars=enc_mess.toCharArray();
			ori_mess=in.next();
			ori_chars=ori_mess.toCharArray();
			Arrays.fill(alpha1,0);
			Arrays.fill(alpha2,0);
			for(int i=0;i<enc_chars.length;i++)
			{
				alpha1[enc_chars[i]-'A']++;
				alpha2[ori_chars[i]-'A']++;
			}
			Arrays.sort(alpha1);
			Arrays.sort(alpha2);
			int flag=0;
			for(int i=0;i<alpha1.length;i++)
				if(alpha1[i]!=alpha2[i])
				{
					flag=1;
					break;
				}
			if(flag==0)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}

}


相关文章推荐

UVA1339-Ancient Cipher

Description Ancient Roman empire had a strong government system with various departments, inclu...

NEERC 2004 / UVa 1339 Ancient Cipher (模拟)

1339 - Ancient Cipher Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_on...

UVa1339 Ancient Cipher

原题: Ancient Roman empire had a strong government system with various departments, including a secre...

UVA - 1339 Ancient Cipher

Description Ancient Roman empirehad a strong government system with various departments, includinga...

UVA 1339 Ancient Cipher古老的密码【NEERC 2004】【刘汝佳紫书4-1】

Ancient Roman empire had a strong government system with various departments, including a secret ser...

uva 1339 Ancient Cipher

原题: Ancient Roman empire had a strong government system with various departments, including a secre...

UVa 1339 Ancient Cipher

Ancient Cipher Ancient Roman empire had a strong government system with various departments, ...

UVa - 1339 - Ancient Cipher(排序)

思路:题目的大概意思是对信息的加密。加密方法有两种。 第一种:Substitution cipher 将字母往后推1位或者更多,如A往后推一位是B。(可以理解为字母的映射),需要注意的是 不同...

Ancient Cipher,NEETC 2004,UVa1339

Ancient Roman empire had a strong government system with various departments, including a secret ser...

1339 - Ancient Cipher

Ancient Roman Empire had a stronggovernment system with various departments, including a secret serv...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Uva1339 Ancient Cipher
举报原因:
原因补充:

(最多只允许输入30个字)