結果
| 問題 |
No.550 夏休みの思い出(1)
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2016-08-14 03:47:03 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 2,000 ms |
| コード長 | 1,884 bytes |
| コンパイル時間 | 2,448 ms |
| コンパイル使用メモリ | 114,708 KB |
| 実行使用メモリ | 18,176 KB |
| 最終ジャッジ日時 | 2024-10-11 05:27:57 |
| 合計ジャッジ時間 | 4,975 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 55 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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 = -(x + b + c); B = bc + xb + xc
// -> A2 := -(b + c) = A + x;
// B2 = bc = B - x(b+c) = B + x*A2;
long A2 = 0;
long B2 = 0;
long D = 0;
A2 = A + alpha; // -(alpha + beta)
B2 = B + alpha*A + alpha*alpha; // alpha * beta
D = A2*A2 - 4*B2;
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));}
}
kuuso1