码迷,mamicode.com
首页 > 其他好文 > 详细

Pokemon Master

时间:2015-04-21 22:19:24      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

Pokemon Master

Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other)
Total Submission(s) : 15   Accepted Submission(s) : 8
Problem Description
Calem and Serena are pokemon masters. One day they decided to have a pokemon battle practice before Pokemon World Championships. Each of them has some pokemons in each‘s team. To make the battle more interesting, they decided to use a special rule to determine the winner: the team with heavier total weight will win the battle!
Input
There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:
The first line contains two integers N and M (1 <= N, M <= 6), which describes that Calem has N pokemons and Serena has M pokemons.
The second line contains N integers indicating the weight of Calem‘s pokemons. The third line contains M integers indicating the weight of Serena‘s pokemons. All pokemons‘ weight are in the range of [1, 2094] pounds.
Output
For each test case, output "Calem" if Calem‘s team will win the battle, or "Serena" if Serena‘s team will win. If the two team have the same total weight, output "Draw" instead.
Sample Input
1
6 6
13 220 199 188 269 1014
101 176 130 220 881 396
Sample Output
Serena
 
package ACM1;


import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Scanner;



public class nyojw2
{
  public static void main(String[]args)
  {
      Scanner scanner = new Scanner(System.in);
      int t = scanner.nextInt();
      for(int i=0;i<t;i++)
      {
         int n = scanner.nextInt();
         int m = scanner.nextInt();
         int sum1=0;
         int sum2=0;
         for(int j=0;j<n;j++)
         {
             sum1=sum1+scanner.nextInt();
             
         }
         for(int j=0;j<m;j++)
         {
             
             sum2=sum2+scanner.nextInt();
         }
         if(sum1==sum2)
             System.out.println("Draw");
         if(sum1<sum2)
             System.out.println("Serena");
         if(sum1>sum2)
             System.out.println("Calem");
          
      }
      
  }
}

当java的数组用不明白的时候减少用数组的频率,因当学一下ArryList 的用法

Pokemon Master

标签:

原文地址:http://www.cnblogs.com/mmlovejj/p/4445470.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!