結果

問題 No.485 方程式のお勉強
ユーザー 37zigen
提出日時 2017-02-24 22:27:52
言語 Java
(openjdk 23)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 413 bytes
コンパイル時間 3,411 ms
コンパイル使用メモリ 74,564 KB
実行使用メモリ 41,412 KB
最終ジャッジ日時 2024-10-04 03:28:02
合計ジャッジ時間 6,501 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

public class Q485 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int sig = (int) Math.signum(A * B);
		A = Math.abs(A);
		B = Math.abs(B);
		for (int i = 0; i < 1000; ++i) {
			if (A * i == B) {
				System.out.println(i*sig);
				return;
			}
		}
		System.out.println("NO");
	}
}
0