結果

問題 No.3072 Sum of sqrt(x)
ユーザー uwiuwi
提出日時 2020-09-12 16:25:38
言語 Java21
(openjdk 21)
結果
OLE  
実行時間 -
コード長 1,958 bytes
コンパイル時間 4,488 ms
コンパイル使用メモリ 82,576 KB
実行使用メモリ 61,828 KB
最終ジャッジ日時 2024-06-10 15:24:21
合計ジャッジ時間 23,919 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
45,884 KB
testcase_01 AC 124 ms
41,808 KB
testcase_02 AC 129 ms
41,384 KB
testcase_03 AC 127 ms
41,528 KB
testcase_04 AC 118 ms
40,752 KB
testcase_05 AC 121 ms
41,628 KB
testcase_06 AC 122 ms
41,384 KB
testcase_07 OLE -
testcase_08 OLE -
testcase_09 OLE -
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package extra;

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class P3072_2 {
	static Scanner in;
	static PrintWriter out;
	static String INPUT = "";

	static void solve()
	{
		int[] a = new int[40];
		int[] h = new int[40];
		for(int T = ni();T > 0;T--){
			long x = nl(); // 00 * 11
			if(x != 0) {
				for (int i = 14; i >= 0; i--) {
					h[i] = (int) (x % 100);
					x /= 100;
				}
				double t = 0;
				double u = 0;
				for (int i = 0; i < 35; i++) {
					for (int s = 1; s <= 10; s++) {
						if ((t + s) * s > u) {
							s--;
							a[i + 5] += s;
							u = (u - (t + s) * s) * 100 + h[i];
							t = (t + 2 * s) * 10;
							break;
						}
					}
				}
				for (int i = 39; i >= 1; i--) {
					if (a[i] >= 10) {
						a[i] -= 10;
						a[i - 1]++;
					}
				}

			}
			int nzf = -1;
			for (int i = 0; i < 40; i++) {
				if (nzf == -1 && a[i] != 0) {
					nzf = i;
				}
				if(nzf == -1 && i == 20){
					nzf = 20;
				}
				if(nzf != -1 && i <= nzf + 18){
					out.print(a[i]);
				}
				if(i == 20){
					out.print(".");
				}
			}
			out.println();
		}
	}

	public static void main(String[] args) throws Exception
	{
//		int n = 1000000, m = 99999;
//		Random gen = new Random();
//		StringBuilder sb = new StringBuilder();
//		sb.append(n + " ");
//		for (int i = 0; i < n; i++) {
//			sb.append(Math.abs(gen.nextLong() % 1000000000000000000L) + " ");
//		}
//		INPUT = sb.toString();


		long S = System.currentTimeMillis();
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);
		
		solve();
		out.flush();
		long G = System.currentTimeMillis();
		tr(G-S+"ms");
	}
	
	static int ni() { return Integer.parseInt(in.next()); }
	static long nl() { return Long.parseLong(in.next()); }
	static double nd() { return Double.parseDouble(in.next()); }
	static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}
0