結果

問題 No.550 夏休みの思い出(1)
ユーザー kuuso1kuuso1
提出日時 2016-08-15 19:47:26
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,972 bytes
コンパイル時間 1,897 ms
コンパイル使用メモリ 113,492 KB
実行使用メモリ 26,568 KB
最終ジャッジ日時 2024-04-19 13:05:52
合計ジャッジ時間 5,410 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
26,224 KB
testcase_01 AC 29 ms
24,432 KB
testcase_02 AC 30 ms
24,048 KB
testcase_03 AC 30 ms
26,092 KB
testcase_04 AC 29 ms
24,392 KB
testcase_05 AC 28 ms
24,180 KB
testcase_06 AC 30 ms
26,312 KB
testcase_07 AC 30 ms
26,348 KB
testcase_08 AC 31 ms
24,180 KB
testcase_09 AC 26 ms
26,180 KB
testcase_10 AC 25 ms
24,436 KB
testcase_11 AC 25 ms
24,312 KB
testcase_12 AC 25 ms
26,436 KB
testcase_13 AC 25 ms
24,048 KB
testcase_14 AC 24 ms
21,944 KB
testcase_15 AC 26 ms
26,328 KB
testcase_16 AC 25 ms
26,568 KB
testcase_17 AC 25 ms
24,372 KB
testcase_18 AC 25 ms
24,432 KB
testcase_19 AC 26 ms
24,112 KB
testcase_20 AC 26 ms
24,304 KB
testcase_21 AC 26 ms
24,264 KB
testcase_22 AC 27 ms
24,136 KB
testcase_23 AC 26 ms
23,920 KB
testcase_24 AC 27 ms
24,308 KB
testcase_25 AC 27 ms
26,352 KB
testcase_26 AC 26 ms
24,272 KB
testcase_27 AC 27 ms
26,220 KB
testcase_28 AC 27 ms
24,148 KB
testcase_29 AC 25 ms
24,404 KB
testcase_30 AC 28 ms
24,304 KB
testcase_31 AC 24 ms
26,188 KB
testcase_32 AC 24 ms
22,200 KB
testcase_33 AC 23 ms
22,328 KB
testcase_34 AC 24 ms
24,056 KB
testcase_35 AC 25 ms
26,188 KB
testcase_36 AC 26 ms
26,316 KB
testcase_37 AC 26 ms
26,188 KB
testcase_38 AC 25 ms
26,096 KB
testcase_39 AC 25 ms
24,432 KB
testcase_40 AC 26 ms
24,312 KB
testcase_41 AC 26 ms
24,436 KB
testcase_42 AC 26 ms
24,400 KB
testcase_43 AC 26 ms
26,312 KB
testcase_44 AC 24 ms
24,496 KB
testcase_45 AC 26 ms
24,180 KB
testcase_46 AC 25 ms
24,312 KB
testcase_47 AC 26 ms
24,428 KB
testcase_48 AC 25 ms
24,008 KB
testcase_49 AC 25 ms
26,564 KB
testcase_50 AC 26 ms
24,180 KB
testcase_51 AC 27 ms
24,048 KB
testcase_52 AC 27 ms
24,312 KB
testcase_53 AC 24 ms
22,192 KB
testcase_54 AC 24 ms
24,312 KB
testcase_55 AC 25 ms
24,184 KB
testcase_56 AC 24 ms
24,308 KB
testcase_57 AC 24 ms
24,244 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using CT = System.Diagnostics.Contracts.Contract;
using System.Numerics;
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<long> L = new List<long>();
		
		long alpha = 0;
		// at least 1 solution with absolute value < 1e6
		for(long j=0;j<1e6;j++){
			if(j*j*j + A*j*j + B*j + C == 0){
				alpha = j;
				L.Add(alpha);
				break;
			}
			if(-j*j*j + A*j*j - B*j + C == 0){
				alpha = -j;
				L.Add(alpha);
				break;
			}
		}
		
		// solve 2-equation y^2 + A2*y + B2 = 0
		// A = -(alpha + beta + gamma); B = alpha*beta + beta*gamma + gamma*alpha
		// -> A2 := -(beta + gamma) = A + alpha;
		//    B2 = beta*gamma = B - alpha (beta + gamma) = B + alpha*A2;
		long A2 = 0;
		long B2 = 0;
		long D = 0;
		A2 = A + alpha;	// -(beta + gamma)
		B2 = B + alpha*A + alpha*alpha;	// beta * gamma
		D = A2*A2 - 4*B2;	// determinant
		long sqrtD = (long)Math.Sqrt((double)D);
		L.Add( (-A2 + sqrtD)/2 );
		L.Add( (-A2 - sqrtD)/2 );
		
		
		L.Sort();
		Console.WriteLine(String.Join(" ",L.ToArray()));
		
	}
	long A,B,C;
	public Sol(){
		var d = rla();
		A = d[0];
		B = d[1];
		C = d[2];
	}
	
	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
0