点击题号跳转

A3604 B5608 C5385 D5003 E2527

F2108 G4712 H3993 I1892 J3842

A.The Table回到顶部

题意

n行m列,问哪一列乘积最大,相同输出m大的,n<=1000,m<=20

题解

曾经做过(07G),大数相乘处理一下就行了,复杂度O(nm)

代码

 1 import java.math.BigInteger;
 2 import java.util.*;
 3 
 4 public class Main {
 5 
 6     public static void main(String[] args) {
 7 
 8         BigInteger[] big = new BigInteger[25];
 9 
10         Scanner sc = new Scanner(System.in);
11         while(sc.hasNext()) {
12             int m = sc.nextInt();
13             int n = sc.nextInt();
14             BigInteger b;
15             for (int i = 1; i <= m; i++)
16                 big[i] = BigInteger.ONE;
17             for (int i = 1; i <= n; i++) {
18                 for (int j = 1; j <= m; j++) {
19                     b = sc.nextBigInteger();
20                     big[j] = big[j].multiply(b);
21                 }
22             }
23             int id = 1;
24             BigInteger maxx = big[1];
25             for (int i = 2; i <= m; i++) {
26                 //System.out.println(maxx.compareTo(big[i]));
27                 if (maxx.compareTo(big[i]) <= 0) {
28                     maxx = big[i];
29                     id = i;
30                 }
31             }
32             System.out.println(id);
33         }
34     }
35 }
A

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2021-12-24
  • 2022-12-23
  • 2021-09-16
  • 2022-01-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案