AtCoder Beginner Contest 001

Submission #226127

Source codeソースコード

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.*;
public class Main {

	public static int N, M;

	public static void main(String[] args) {
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			PrintWriter pw = new PrintWriter(System.out);

			String[] param = br.readLine().split(" ");
			int Deg = Integer.parseInt(param[0]); 
			int Dis = Integer.parseInt(param[1]);
			pw.println(calc(Deg, Dis)); 

			pw.close();
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
			return;
		}
	}

	public static double[][] DirRange = new double[16][2];
	public static String[] DirName = new String[16];
	public static double[][] WindowRange = new double[13][2];
	public static void init(){
		WindowRange[0][0]=0.0; WindowRange[0][1]=0.2; WindowRange[5][0]=8.0; WindowRange[5][1]=10.7; WindowRange[10][0]=24.5; WindowRange[10][1]=28.4;
		WindowRange[1][0]=0.3; WindowRange[1][1]=1.5; WindowRange[6][0]=10.8; WindowRange[6][1]=13.8; WindowRange[11][0]=28.5; WindowRange[11][1]=32.6;
		WindowRange[2][0]=1.6; WindowRange[2][1]=3.3; WindowRange[7][0]=13.9; WindowRange[7][1]=17.1; WindowRange[12][0]=32.7; WindowRange[12][1]=0;
		WindowRange[3][0]=3.4; WindowRange[3][1]=5.4; WindowRange[8][0]=17.2; WindowRange[8][1]=20.7;
		WindowRange[4][0]=5.5; WindowRange[4][1]=7.9; WindowRange[9][0]=20.8; WindowRange[9][1]=24.4;
		DirName[0] = "N";	DirName[8]="S"; DirRange[8][0]=168.75; DirRange[8][1]=191.25;
		DirName[1] = "NNE"; DirRange[1][0]=11.25; DirRange[1][1]=33.75; 	DirName[9]="SSW"; DirRange[9][0]=191.25; DirRange[9][1]=213.75;
		DirName[2] = "NE"; 	DirRange[2][0]=33.75; DirRange[2][1]=56.25; 	DirName[10]="SW"; DirRange[10][0]=213.75; DirRange[10][1]=236.25;
		DirName[3] = "ENE"; DirRange[3][0]=56.25; DirRange[3][1]=78.75; 	DirName[11]="WSW"; DirRange[11][0]=236.25; DirRange[11][1]=258.75;
		DirName[4] = "E"; 	DirRange[4][0]=78.75; DirRange[4][1]=101.25; 	DirName[12]="W"; DirRange[12][0]=258.75; DirRange[12][1]=281.25;
		DirName[5] = "ESE"; DirRange[5][0]=101.25; DirRange[5][1]=123.75; 	DirName[13]="WNW"; DirRange[13][0]=281.25; DirRange[13][1]=303.75;
		DirName[6] = "SE"; 	DirRange[6][0]=123.75; DirRange[6][1]=146.25; 	DirName[14]="NW"; DirRange[14][0]=303.75; DirRange[14][1]=326.25;
		DirName[7] = "SSE"; DirRange[7][0]=146.25; DirRange[7][1]=168.75; 	DirName[15]="NNW"; DirRange[15][0]=326.25; DirRange[15][1]=348.75;
	}

	public static String calc(int deg, int dis){
		init();
		int W = getW(dis);
		String Dir = getDir(deg);
		
		if(W==0){
			Dir = "C";
		}

		return Dir + " " + W;
	}

	public static String getDir(int dir){
		double Dir = dir / 10.0;
		for(int i=1;i<16;i++){
			if(DirRange[i][0]<=Dir && Dir <DirRange[i][1]){
				return DirName[i];
			}
		}
		return DirName[0];
	}
	public static int getW(int dis){
		BigDecimal bd = new BigDecimal(String.valueOf(dis/60.0));
		double Dis = bd.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
		for(int i=0;i<12;i++){
			if(WindowRange[i][0]<=Dis && Dis <=WindowRange[i][1]){
				return i;
			}
		}
		return 12;
	}
}

Submission

Task問題 C - 風力観測
User nameユーザ名 ih_sk
Created time投稿日時
Language言語 Java (OpenJDK 1.7.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 3199 Byte
File nameファイル名
Exec time実行時間 432 ms
Memory usageメモリ使用量 21432 KB

Test case

Set

Set name Score得点 / Max score Cases
all 100 / 100 00_sample_01.txt,00_sample_02.txt,00_sample_03.txt,00_sample_04.txt,00_sample_05.txt,00_sample_06.txt,00_sample_07.txt,00_sample_08.txt,test_01.txt,test_02.txt,test_03.txt,test_04.txt,test_05.txt,test_06.txt,test_07.txt,test_08.txt,test_09.txt,test_10.txt,test_11.txt,test_12.txt,test_13.txt,test_14.txt,test_15.txt,test_16.txt,test_17.txt,test_18.txt,test_19.txt,test_20.txt,test_21.txt,test_22.txt,test_23.txt,test_24.txt,test_25.txt,test_26.txt,test_27.txt,test_28.txt,test_29.txt,test_30.txt,test_31.txt,test_32.txt,test_33.txt,test_34.txt,test_35.txt,test_36.txt,test_37.txt,test_38.txt,test_39.txt,test_40.txt,test_41.txt,test_42.txt,test_43.txt,test_44.txt,test_45.txt,test_46.txt,test_47.txt,test_48.txt,test_49.txt,test_50.txt,test_51.txt,test_52.txt,test_53.txt,test_54.txt,test_55.txt,test_56.txt,test_57.txt,test_58.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_sample_01.txt AC 389 ms 21292 KB
00_sample_02.txt AC 388 ms 21424 KB
00_sample_03.txt AC 395 ms 21296 KB
00_sample_04.txt AC 386 ms 21288 KB
00_sample_05.txt AC 387 ms 21300 KB
00_sample_06.txt AC 380 ms 21296 KB
00_sample_07.txt AC 382 ms 21428 KB
00_sample_08.txt AC 385 ms 21296 KB
test_01.txt AC 388 ms 21416 KB
test_02.txt AC 392 ms 21424 KB
test_03.txt AC 387 ms 21300 KB
test_04.txt AC 385 ms 21172 KB
test_05.txt AC 403 ms 21296 KB
test_06.txt AC 390 ms 21424 KB
test_07.txt AC 393 ms 21300 KB
test_08.txt AC 421 ms 21292 KB
test_09.txt AC 399 ms 21272 KB
test_10.txt AC 383 ms 21268 KB
test_11.txt AC 390 ms 21356 KB
test_12.txt AC 378 ms 21336 KB
test_13.txt AC 380 ms 21304 KB
test_14.txt AC 400 ms 21280 KB
test_15.txt AC 401 ms 21424 KB
test_16.txt AC 398 ms 21428 KB
test_17.txt AC 391 ms 21300 KB
test_18.txt AC 386 ms 21300 KB
test_19.txt AC 387 ms 21300 KB
test_20.txt AC 409 ms 21296 KB
test_21.txt AC 393 ms 21300 KB
test_22.txt AC 394 ms 21292 KB
test_23.txt AC 392 ms 21300 KB
test_24.txt AC 398 ms 21424 KB
test_25.txt AC 397 ms 21268 KB
test_26.txt AC 401 ms 21420 KB
test_27.txt AC 401 ms 21292 KB
test_28.txt AC 432 ms 21284 KB
test_29.txt AC 387 ms 21432 KB
test_30.txt AC 401 ms 21284 KB
test_31.txt AC 393 ms 21424 KB
test_32.txt AC 389 ms 21292 KB
test_33.txt AC 388 ms 21300 KB
test_34.txt AC 393 ms 21352 KB
test_35.txt AC 407 ms 21264 KB
test_36.txt AC 393 ms 21268 KB
test_37.txt AC 389 ms 21420 KB
test_38.txt AC 389 ms 21292 KB
test_39.txt AC 390 ms 21324 KB
test_40.txt AC 394 ms 21408 KB
test_41.txt AC 393 ms 21296 KB
test_42.txt AC 385 ms 21396 KB
test_43.txt AC 394 ms 21296 KB
test_44.txt AC 394 ms 21292 KB
test_45.txt AC 386 ms 21280 KB
test_46.txt AC 385 ms 21300 KB
test_47.txt AC 383 ms 21424 KB
test_48.txt AC 388 ms 21296 KB
test_49.txt AC 391 ms 21292 KB
test_50.txt AC 383 ms 21304 KB
test_51.txt AC 403 ms 21292 KB
test_52.txt AC 391 ms 21428 KB
test_53.txt AC 397 ms 21428 KB
test_54.txt AC 382 ms 21420 KB
test_55.txt AC 399 ms 21232 KB
test_56.txt AC 386 ms 21296 KB
test_57.txt AC 388 ms 21424 KB
test_58.txt AC 396 ms 21296 KB