結果
| 問題 |
No.2358 xy+yz+zx=N
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2024-05-02 14:13:59 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 718 ms / 2,000 ms |
| コード長 | 2,088 bytes |
| コンパイル時間 | 2,875 ms |
| コンパイル使用メモリ | 83,548 KB |
| 実行使用メモリ | 50,000 KB |
| 最終ジャッジ日時 | 2024-11-23 04:37:30 |
| 合計ジャッジ時間 | 8,709 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner();
int n = sc.nextInt();
List<Answer> ans = new ArrayList<>();
for (int i = 0; i * i <= n; i++) {
for (int j = i; j * i <= n && j <= n; j++) {
if (i == 0 && j == 0) {
continue;
}
if ((n - i * j) % (i + j) == 0) {
ans.add(new Answer((n - i * j) / (i + j), i, j));
if (i < j) {
ans.add(new Answer((n - i * j) / (i + j), j, i));
}
}
}
}
System.out.println(ans.size());
System.out.println(ans.stream().map(x -> x.toString()).collect(Collectors.joining("\n")));
}
static class Answer {
int a;
int b;
int c;
public Answer(int a, int b, int c) {
this.a = a;
this.b = b;
this.c = c;
}
public String toString() {
return a + " " + b + " " + c;
}
}
}
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