結果
問題 |
No.1006 Share an Integer
|
ユーザー |
![]() |
提出日時 | 2020-03-13 21:00:04 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,568 bytes |
コンパイル時間 | 2,503 ms |
コンパイル使用メモリ | 79,900 KB |
実行使用メモリ | 115,844 KB |
最終ジャッジ日時 | 2024-11-22 18:24:09 |
合計ジャッジ時間 | 38,916 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 TLE * 11 |
ソースコード
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author silviase */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); split solver = new split(); solver.solve(1, in, out); out.close(); } static class split { public void solve(int testNumber, Scanner in, PrintWriter out) { int x = in.nextInt(); int[] a = new int[x + 1]; for (int i = 0; i <= x; i++) { a[i] = i; } for (int i = 1; i <= x; i++) { for (int j = 1; j <= x; j++) { if (j % i == 0) { a[j]--; } } } StringBuilder sb = new StringBuilder(); int min = 100000000; for (int i = 1; i < x; i++) { int cmp = Math.abs(a[i] - a[x - i]); if (min == cmp) { sb.append(i + " " + (x - i) + "\n"); } else if (min > cmp) { sb = new StringBuilder(i + " " + (x - i) + "\n"); min = cmp; } } out.print(sb.toString()); } } }