結果

問題 No.550 夏休みの思い出(1)
ユーザー 37zigen37zigen
提出日時 2017-07-29 16:56:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 354 ms / 2,000 ms
コード長 1,605 bytes
コンパイル時間 2,531 ms
コンパイル使用メモリ 82,628 KB
実行使用メモリ 48,332 KB
最終ジャッジ日時 2024-04-19 13:18:10
合計ジャッジ時間 22,263 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 340 ms
48,332 KB
testcase_01 AC 299 ms
46,360 KB
testcase_02 AC 309 ms
47,308 KB
testcase_03 AC 326 ms
47,644 KB
testcase_04 AC 352 ms
46,764 KB
testcase_05 AC 328 ms
47,796 KB
testcase_06 AC 330 ms
47,008 KB
testcase_07 AC 352 ms
46,972 KB
testcase_08 AC 304 ms
46,988 KB
testcase_09 AC 306 ms
47,108 KB
testcase_10 AC 325 ms
46,324 KB
testcase_11 AC 317 ms
47,160 KB
testcase_12 AC 313 ms
47,824 KB
testcase_13 AC 338 ms
46,936 KB
testcase_14 AC 300 ms
47,492 KB
testcase_15 AC 308 ms
45,964 KB
testcase_16 AC 354 ms
46,036 KB
testcase_17 AC 341 ms
46,636 KB
testcase_18 AC 305 ms
46,108 KB
testcase_19 AC 338 ms
46,116 KB
testcase_20 AC 295 ms
46,092 KB
testcase_21 AC 293 ms
45,516 KB
testcase_22 AC 331 ms
47,400 KB
testcase_23 AC 302 ms
46,716 KB
testcase_24 AC 310 ms
46,700 KB
testcase_25 AC 318 ms
46,760 KB
testcase_26 AC 318 ms
45,856 KB
testcase_27 AC 302 ms
46,508 KB
testcase_28 AC 316 ms
46,852 KB
testcase_29 AC 325 ms
47,016 KB
testcase_30 AC 309 ms
46,992 KB
testcase_31 AC 322 ms
46,852 KB
testcase_32 AC 300 ms
46,560 KB
testcase_33 AC 318 ms
46,632 KB
testcase_34 AC 320 ms
47,068 KB
testcase_35 AC 313 ms
47,296 KB
testcase_36 AC 307 ms
47,636 KB
testcase_37 AC 343 ms
46,956 KB
testcase_38 AC 310 ms
46,744 KB
testcase_39 AC 310 ms
46,892 KB
testcase_40 AC 311 ms
46,340 KB
testcase_41 AC 312 ms
46,060 KB
testcase_42 AC 314 ms
47,160 KB
testcase_43 AC 318 ms
46,024 KB
testcase_44 AC 312 ms
47,456 KB
testcase_45 AC 314 ms
47,300 KB
testcase_46 AC 338 ms
46,596 KB
testcase_47 AC 346 ms
46,924 KB
testcase_48 AC 330 ms
46,060 KB
testcase_49 AC 271 ms
46,796 KB
testcase_50 AC 306 ms
47,424 KB
testcase_51 AC 306 ms
48,280 KB
testcase_52 AC 316 ms
46,856 KB
testcase_53 AC 308 ms
46,020 KB
testcase_54 AC 314 ms
45,484 KB
testcase_55 AC 333 ms
46,920 KB
testcase_56 AC 318 ms
47,080 KB
testcase_57 AC 316 ms
47,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	static long time = 0;

	public void run() {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		BigInteger a = BigInteger.valueOf(A);
		BigInteger b = BigInteger.valueOf(B);
		BigInteger c = BigInteger.valueOf(C);
		BigInteger MOD = BigInteger.valueOf(33331);
		A %= 33331;
		B %= 33331;
		C %= 33331;
		ArrayList<Long> ans = new ArrayList<>();
		for (long i = 0; i < 33331; ++i) {
			if (f(A, B, C, i, 33331) % 33331 == 0) {
				for (long j = -33331L * 33331L; j < 33331L * 33331L; j += 33331) {
					long v = i + j;
					if (f(a, b, c, BigInteger.valueOf(v)).equals(BigInteger.ZERO))
						ans.add(v);
				}
			}
		}
		Collections.sort(ans);
		for (int i = 0; i < ans.size(); ++i) {
			System.out.print(ans.get(i) + (i == ans.size() - 1 ? "\n" : " "));
		}
	}

	BigInteger f(BigInteger a, BigInteger b, BigInteger c, BigInteger v) {
		BigInteger ans = new BigInteger("0");
		ans = ans.add(v.multiply(v).multiply(v));
		ans = ans.add(v.multiply(v).multiply(a));
		ans = ans.add(v.multiply(b));
		ans = ans.add(c);
		return ans;
	}

	long f(long a, long b, long c, long v, long MOD) {
		long ans = 0;
		ans = v * v % MOD * v + a * v % MOD * v;
		ans %= MOD;
		ans += v * b;
		ans += c;
		ans %= MOD;
		return ans;
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0