結果

問題 No.313 π
ユーザー uafr_cs
提出日時 2015-12-06 00:16:21
言語 Java
(openjdk 23)
結果
AC  
実行時間 186 ms / 5,000 ms
コード長 1,688 bytes
コンパイル時間 2,497 ms
コンパイル使用メモリ 78,912 KB
実行使用メモリ 43,052 KB
最終ジャッジ日時 2024-09-14 14:54:32
合計ジャッジ時間 9,723 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	static int[] counts = new int[]{
			20104,
			20063,
			19892,
			20011,
			19874,
			20199,
			19898,
			20163,
			19956,
			19841
	};
	
	public static int[] process(char[] inputs, boolean output){
		int[] arr = new int[10];
		for(final char ch : inputs){
			if(!Character.isDigit(ch)){ continue; }
			
			arr[Character.getNumericValue(ch)]++;
		}
		
		if(!output){ return arr; }
		
		
		for(final int a : arr){ System.out.println(a + ","); }
		
		return arr;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char[] input = sc.next().toCharArray();
		boolean debug = false;
		
		int[] arr = process(input, debug);
		
		
		int less = -1, more = -1;
		for(int i = 0; i < 10; i++){
			if(counts[i] < arr[i]){
				more = i;
			}else if(counts[i] > arr[i]){
				less = i;
			}
		}
		
		System.out.println(more + " " + less);
	}
	
	public static class Scanner {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() {
			try {
				while (!hasNext()) {tok = new StringTokenizer(br.readLine());}
			} catch(IOException e){ /* ignore */ }
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() {
			getLine(); return tok.nextToken();
		}

		public int nextInt(){
			return Integer.parseInt(next());
		}

		public void close() {
			try{ br.close(); } catch (IOException e){ /*ignore*/ }
		}
	}
}
0