zoukankan      html  css  js  c++  java
  • Pokemon Master

    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 的用法

  • 相关阅读:
    TreeSet类的排序问题
    TreeSet()详解
    css中vertical-align垂直居中的认识
    CSS3 float深入理解浮动资料整理
    层叠顺序与层叠上下文
    jquery.zclip轻量级复制失效问题
    文章转载利用border、transparent实现微风
    转载利用线性渐变实现晴天、多云特效
    转载利用伪元素单个颜色实现 hover 和 active 时的明暗变化效果
    MUI-最接近原生App体验的前端框架
  • 原文地址:https://www.cnblogs.com/mmlovejj/p/4445470.html
Copyright © 2011-2022 走看看