結果
問題 |
No.550 夏休みの思い出(1)
|
ユーザー |
![]() |
提出日時 | 2017-08-04 00:41:38 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,205 bytes |
コンパイル時間 | 1,148 ms |
コンパイル使用メモリ | 109,952 KB |
実行使用メモリ | 20,736 KB |
最終ジャッジ日時 | 2024-10-11 20:37:53 |
合計ジャッジ時間 | 4,711 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 WA * 53 |
コンパイルメッセージ
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; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ Func<double,double,double,List<double>> solve2 = (a, b, c) =>{ var ret = new List<double>(){ (-b - Math.Sqrt(b * b - 4 * a * c)) / (2 * a), (-b + Math.Sqrt(b * b - 4 * a * c)) / (2 * a), }; ret.Sort(); return ret; }; Func<double, double> f = x => x*x*x + (double) A * x * x + (double) B * x + (double) C; Func<double, double> nf = x => -f(x); Func<long, long> fl = x => x*x*x + A * x * x + B * x + C; var ps = solve2(3, 2*(double)A, (double) B); Func<Func<double,double>,double,double,double> bins = (g, l, r) =>{ double Eps = 1e-9; for(int t=0;t<100;t++){ double c = (l + r) / 2.0; if(g(c) < -Eps){ l = c; } else { r = c; } } return (l + r) / 2.0; }; Func<double,List<long>> lins = t =>{ var ret = new List<long>(); for(long x = (long) t - 200; x < (long) t + 200;x++){ if(f(x) == 0) ret.Add(x); } return ret; }; List<double> candi = new List<double>(){ bins(f, -1.1e9, ps[0]), bins(nf, ps[0], ps[1]), bins(f, ps[1], 1.1e9), }; HashSet<long> H = new HashSet<long>(); foreach(var xx in candi){ var xls = lins(xx); foreach(var xl in xls) H.Add(xl); } var ans = H.ToList(); ans.Sort(); Console.WriteLine(String.Join(" ",ans)); } 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));} }