結果
| 問題 |
No.2016 Countdown Divisors
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2024-07-30 10:33:13 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,845 bytes |
| コンパイル時間 | 2,311 ms |
| コンパイル使用メモリ | 82,984 KB |
| 実行使用メモリ | 63,512 KB |
| 最終ジャッジ日時 | 2024-07-30 10:33:21 |
| 合計ジャッジ時間 | 6,911 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | AC * 1 TLE * 1 -- * 17 |
ソースコード
import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
public class Main {
static Map<Integer, Integer> dp = new HashMap<>();
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner();
int n = sc.nextInt();
dp.put(1, 1);
dp.put(2, 2);
String result = IntStream.range(0, n)
.mapToObj(i -> String.valueOf(dfw(sc.nextInt())))
.collect(Collectors.joining("\n"));
System.out.println(result);
}
static int dfw(int x) {
if (!dp.containsKey(x)) {
int count = 0;;
for (int i = 1; i * i <= x; i++) {
if (x % i == 0) {
if (i * i == x) {
count++;
} else {
count += 2;
}
}
}
dp.put(x, dfw(x - count));
}
return dp.get(x);
}
}
class Scanner {
BufferedReader br;
StringTokenizer st = new StringTokenizer("");
StringBuilder sb = new StringBuilder();
public Scanner() {
try {
br = new BufferedReader(new InputStreamReader(System.in));
} catch (Exception e) {
}
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public double nextDouble() {
return Double.parseDouble(next());
}
public String next() {
try {
while (!st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return st.nextToken();
}
}
}
tenten