1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | import java.util.*; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int N1 = sc.nextInt(); int N2 = sc.nextInt(); int N3 = sc.nextInt(); int Size = N1 * N2 * N3; int[] answerArray = new int[Size]; int answerIdx = 0; for(int i=1; i<=N1; i++){ for(int j=1; j<=N2; j++){ for(int k=1; k<=N3; k++){ answerArray[answerIdx++] = i + j + k; } } } Arrays.sort(answerArray); int currentNum = answerArray[0]; int maxNum = answerArray[0]; int currentCnt = 1; int maxCnt = 1; for(int i=1; i<answerArray.length; i++){ if(currentNum != answerArray[i]){ if(maxCnt < currentCnt){ maxNum = currentNum; maxCnt = currentCnt; } currentNum = answerArray[i]; currentCnt = 1; }else{ currentCnt++; } } System.out.println(maxNum); } } |
Labels
Programming
(16)
Algorithm
(15)
Java
(15)
ASP .NET
(4)
Enterprise Architecture
(4)
PHP and MySQL
(4)
Software Engineering
(2)
C#
(1)
Data Mining
(1)
Deep Learning
(1)
Java Script
(1)
Python
(1)
Sunday, October 18, 2015
주사위
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment