Problem A -- 人品

http://202.117.21.117/xjoj/contestProblem.php?cid=75&pid=577
 1 //author:pz
 2 
 3 import java.awt.*;
 4 import java.io.*;
 5 import java.util.*;
 6 import java.lang.*;
 7 
 8 class Main {
 9     public static void main(String[] args) {
10         Scanner in = new Scanner(new BufferedInputStream(System.in));        
11         int t = in.nextInt();
12         for (int index = 1; index <= t; ++index) {
13             int n = in.nextInt();
14             int a = in.nextInt();
15             int b = in.nextInt();
16             int c = in.nextInt();
17             in.nextLine();//真心求教这个,我是试了9次才过的,没有这个不行,为什么啊?
18             int maxRp = 0;
19             String maxRpString = null;
20             for (int i = 0; i < n; ++i) {
21                 String s = in.nextLine();
22                 int rp = rp(s, a, b, c);
23                 if (rp > maxRp) {
24                     maxRp = rp;
25                     maxRpString = s;
26                 }
27             }
28             System.out.println("Case #" + index + ": " + maxRpString + " "
29                     + maxRp);
30         }
31     }
32 
33     private static int rp(String s, int a, int b, int c) {
34         int rp = 0;
35         for (int i = 0; i < s.length(); ++i) {
36             rp += (a * (s.charAt(i)) + b) * (s.charAt(i)) + c;
37         }
38         return rp;
39     }
40 
41 }

 

posted on 2013-05-12 18:47  P,Z  阅读(213)  评论(0编辑  收藏  举报