結果

問題 No.456 Millions of Submits!
ユーザー kuuso1kuuso1
提出日時 2016-12-08 22:28:36
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 2,391 ms / 4,500 ms
コード長 5,709 bytes
コンパイル時間 3,216 ms
コンパイル使用メモリ 112,408 KB
実行使用メモリ 149,648 KB
最終ジャッジ日時 2024-06-09 06:25:06
合計ジャッジ時間 11,308 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
19,712 KB
testcase_01 AC 24 ms
19,712 KB
testcase_02 AC 22 ms
19,840 KB
testcase_03 AC 22 ms
19,584 KB
testcase_04 AC 23 ms
19,584 KB
testcase_05 AC 24 ms
19,584 KB
testcase_06 AC 23 ms
19,584 KB
testcase_07 AC 26 ms
19,840 KB
testcase_08 AC 26 ms
19,968 KB
testcase_09 AC 48 ms
20,992 KB
testcase_10 AC 48 ms
20,992 KB
testcase_11 AC 258 ms
34,560 KB
testcase_12 AC 2,391 ms
149,648 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.Threading.Tasks;
using System.IO;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		

		
		String[] Ans = new String[M];
		//Parallel.For(0,M,i=>{
		for(int i=0;i<M;i++){
			double a = A[i];
			double b = B[i];
			double t = T[i];
			
			//Console.WriteLine("{0} {1} {2}",a,b,t);
			
			Func<double,double> f = x => a * Math.Log(x) + b * Math.Log(Math.Log(x)) - Math.Log(t);
			Func<double,double> df = x => a / x + b / x / Math.Log(x);
			
			double xx = 1 + 1e-12;
			if(B[i] == 0){
				xx = Math.Pow(t,1.0/a);
			}else if(A[i] == 0){
				xx = Math.Exp(Math.Pow(t,1.0/b));
			
			}else{
				for(int j=0;j<20;j++){
					var lx = Math.Log(xx);
					var yy = xx - (a * lx + b * Math.Log(lx) - Math.Log(t)) / ( a / xx + b / (xx * lx));
					if(yy - xx < 1e-12)break;
					xx = yy;
				}
			}
			//Console.WriteLine("{0},{1},{2},{3},{4}",a,b,t,xx,f(xx)+t);
			Ans[i] = String.Format("{0:F11}",xx);
		}
		//});
		var sb = new StringBuilder();
		for(int i=0;i<M;i++) sb.AppendLine(Ans[i]);
		Console.Write(sb.ToString());
		
		
	}
	int M;
	int[] A,B;
	double[] T;
	public Sol(){
		using(var r = new FastIn(1000000)){
			M = r.ReadInt();
			A = new int[M];
			B = new int[M];
			T = new double[M];
			for(int i=0;i<M;i++){
				A[i] = r.ReadInt();
				B[i] = r.ReadInt();
				T[i] = r.ReadDouble();
			}
		}
	}
	
	static double Newton(double x, Func<double,double> f, Func<double,double> df) {
		// f(x)=0 => ret x-f(x)/df(x);
		return x - f(x)/df(x);
	}

	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));}
}

class FastIn:IDisposable {
	int Size;
	byte[] Mem;
	int ptr;
	int rsize;
	bool unfinished;
	Stream stdin;
	void Init(int n) {
		Size = n;
		Mem = new byte[Size];
		rsize=(stdin=Console.OpenStandardInput()).Read(Mem, 0, Size);
		ptr = 0;
		unfinished=(rsize == Size);
	}
	void Next() {
		if (unfinished == false) return;
		rsize=stdin.Read(Mem, 0, Size);
		ptr = 0;
		unfinished = (rsize == Size);
	}
	
	~FastIn(){
		stdin.Dispose();
	}
	void IDisposable.Dispose(){
		stdin.Dispose();
	}
	public void Dispose(){
		stdin.Dispose();
	}
	
	public FastIn() {
		Init(100000);
	}
	public FastIn(int n) {
		Init(n);
	}
	public int ReadInt() {
		int ret = 0;
		int sig = 1;
		while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' && Mem[ptr] != '\r' ) {
			if(ret==0 && Mem[ptr] == '-'){
				sig *= -1; ptr++; continue;
			}
			ret = ret * 10 + Mem[ptr++] - '0';
			if (ptr == Size) Next();
		}
		while (ptr < rsize && (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r') ) {
			ptr++;
			if (ptr == Size) Next();
		}
		return ret*sig;
	}
	public double ReadDouble() {
		double ret = 0;
		double sig = 1;
		bool dot = false;
		double keta = 0.1;
		while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' && Mem[ptr] != '\r' ) {
			if(ret==0 && Mem[ptr] == '-'){
				sig *= -1; ptr++;
				if (ptr == Size) Next();
				continue;
			}
			if(Mem[ptr] == '.'){
				dot = true;
				ptr++;
				if (ptr == Size) Next();
				continue;
			}
			if(!dot){
				ret = ret * 10 + Mem[ptr++] - '0';
				if (ptr == Size) Next();
			}else{
				ret = ret + (Mem[ptr++] - '0')*keta;
				keta /= 10.0;
				if (ptr == Size) Next();
			}
		}
		while (ptr < rsize && (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r') ) {
			ptr++;
			if (ptr == Size) Next();
		}
		return ret*sig;
	}
	
	public uint ReadUint() {
		uint ret = 0;
		uint sig = 1;
		while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' && Mem[ptr] != '\r' ) {
			ret = ret * 10 + Mem[ptr++] - '0';
			if (ptr == Size) Next();
		}
		while (ptr < rsize && (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r') ) {
			ptr++;
			if (ptr == Size) Next();
		}
		return ret*sig;
	}
	public long ReadLong() {
		long ret = 0;
		long sig = 1;
		while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' && Mem[ptr] != '\r' ) {
			if(ret==0 && Mem[ptr] == '-'){
				sig *= -1; ptr++; continue;
			}
			ret = ret * 10 + Mem[ptr++] - '0';
			if (ptr == Size) Next();
		}
		while (ptr < rsize &&  (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')  ) {
			ptr++;
			if (ptr == Size) Next();
		}
		return ret*sig;
	}
	public String ReadStr() {
		//2byte文字はNG
		StringBuilder sb = new StringBuilder();
		while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' && Mem[ptr] != '\r') {
			sb.Append((char)Mem[ptr++]);
			if (ptr == Size && unfinished) Next();
		}
		while (ptr < rsize &&  (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r') ) {
			ptr++;
			if (ptr == Size && unfinished) Next();
		}
		return sb.ToString();
	}
	public String ReadLine() {
		//極力使わない(split/parseするくらいなら上をつかう)
		StringBuilder sb = new StringBuilder();
		while (ptr < rsize && Mem[ptr] != '\n' && Mem[ptr] != '\r') {
			sb.Append((char)Mem[ptr++]);
			if (ptr == Size && unfinished) Next();
		}
		while (ptr < rsize &&  (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')) {
			ptr++;
			if (ptr == Size && unfinished) Next();
		}
		return sb.ToString();
	}
}
0