結果

問題 No.648  お や す み 
ユーザー uafr_csuafr_cs
提出日時 2018-02-09 22:33:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 2,353 bytes
コンパイル時間 2,499 ms
コンパイル使用メモリ 76,088 KB
実行使用メモリ 49,764 KB
最終ジャッジ日時 2023-10-11 21:56:38
合計ジャッジ時間 8,762 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,400 KB
testcase_01 AC 43 ms
49,508 KB
testcase_02 AC 44 ms
49,280 KB
testcase_03 AC 43 ms
49,376 KB
testcase_04 AC 45 ms
49,396 KB
testcase_05 AC 46 ms
49,448 KB
testcase_06 AC 45 ms
49,344 KB
testcase_07 AC 44 ms
49,456 KB
testcase_08 AC 45 ms
49,352 KB
testcase_09 AC 45 ms
49,748 KB
testcase_10 AC 43 ms
49,320 KB
testcase_11 AC 43 ms
49,320 KB
testcase_12 AC 44 ms
49,284 KB
testcase_13 AC 44 ms
49,432 KB
testcase_14 AC 45 ms
47,372 KB
testcase_15 AC 45 ms
49,224 KB
testcase_16 AC 45 ms
49,516 KB
testcase_17 AC 44 ms
49,320 KB
testcase_18 AC 45 ms
49,452 KB
testcase_19 AC 44 ms
49,340 KB
testcase_20 AC 45 ms
49,356 KB
testcase_21 AC 44 ms
49,436 KB
testcase_22 AC 44 ms
49,288 KB
testcase_23 AC 44 ms
49,436 KB
testcase_24 AC 44 ms
49,340 KB
testcase_25 AC 44 ms
49,312 KB
testcase_26 AC 44 ms
49,588 KB
testcase_27 AC 44 ms
49,584 KB
testcase_28 AC 44 ms
49,292 KB
testcase_29 AC 44 ms
49,276 KB
testcase_30 AC 45 ms
49,232 KB
testcase_31 AC 45 ms
49,376 KB
testcase_32 AC 45 ms
49,232 KB
testcase_33 AC 44 ms
49,280 KB
testcase_34 AC 45 ms
49,764 KB
testcase_35 AC 44 ms
49,244 KB
testcase_36 AC 44 ms
49,432 KB
testcase_37 AC 44 ms
49,312 KB
testcase_38 AC 44 ms
49,336 KB
testcase_39 AC 44 ms
49,280 KB
testcase_40 AC 44 ms
49,252 KB
testcase_41 AC 44 ms
49,284 KB
testcase_42 AC 44 ms
49,356 KB
testcase_43 AC 44 ms
49,432 KB
testcase_44 AC 45 ms
49,740 KB
testcase_45 AC 44 ms
47,472 KB
testcase_46 AC 44 ms
49,368 KB
testcase_47 AC 44 ms
49,332 KB
testcase_48 AC 44 ms
49,276 KB
testcase_49 AC 44 ms
49,292 KB
testcase_50 AC 45 ms
49,600 KB
testcase_51 AC 44 ms
49,300 KB
testcase_52 AC 44 ms
49,368 KB
testcase_53 AC 44 ms
49,336 KB
testcase_54 AC 44 ms
49,220 KB
testcase_55 AC 44 ms
49,260 KB
testcase_56 AC 44 ms
49,420 KB
testcase_57 AC 44 ms
49,440 KB
testcase_58 AC 43 ms
49,400 KB
testcase_59 AC 45 ms
49,588 KB
testcase_60 AC 44 ms
49,504 KB
testcase_61 AC 44 ms
49,304 KB
testcase_62 AC 44 ms
49,388 KB
testcase_63 AC 44 ms
49,276 KB
testcase_64 AC 44 ms
49,312 KB
testcase_65 AC 44 ms
49,356 KB
testcase_66 AC 44 ms
49,288 KB
testcase_67 AC 45 ms
49,452 KB
testcase_68 AC 45 ms
49,312 KB
testcase_69 AC 44 ms
49,444 KB
testcase_70 AC 44 ms
49,764 KB
testcase_71 AC 45 ms
49,316 KB
testcase_72 AC 44 ms
49,300 KB
testcase_73 AC 44 ms
49,288 KB
testcase_74 AC 43 ms
49,364 KB
testcase_75 AC 44 ms
49,592 KB
testcase_76 AC 43 ms
49,296 KB
testcase_77 AC 45 ms
49,520 KB
testcase_78 AC 44 ms
49,380 KB
testcase_79 AC 42 ms
49,304 KB
testcase_80 AC 43 ms
49,380 KB
testcase_81 AC 43 ms
49,280 KB
testcase_82 AC 43 ms
49,280 KB
testcase_83 AC 43 ms
49,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final long N = sc.nextLong();
			
			final long sqrt = (long)(Math.sqrt(2 * N));
			//System.out.println(sqrt + " " + (sqrt * (sqrt + 1) / 2));
			if((sqrt) * (sqrt + 1) / 2 == N){
				System.out.println("YES");
				System.out.println(sqrt);
				return;
			}
			if((sqrt + 1) * (sqrt + 2) / 2 == N){
				System.out.println("YES");
				System.out.println(sqrt + 1);
				return;
			}
			
			System.out.println("NO");
			
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}
0