結果
問題 | No.456 Millions of Submits! |
ユーザー |
|
提出日時 | 2016-12-08 18:13:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,933 bytes |
コンパイル時間 | 684 ms |
コンパイル使用メモリ | 68,804 KB |
実行使用メモリ | 33,368 KB |
最終ジャッジ日時 | 2024-06-23 16:09:08 |
合計ジャッジ時間 | 5,562 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 WA * 12 |
ソースコード
#include <cstdio>#include <vector>#include <algorithm>#include <array>#include <cmath>#include <cassert>#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)using namespace std;const double eps = 1e-10;double newton(int a, int b, double t, double n) {assert (a >= 1 and b >= 1);auto f = [&](double n) {return pow(n, a) * pow(log(n), b);};auto f1 = [&](double n) {return a * pow(n, a-1) * pow(log(n), b) + pow(n, a) * b * 1/n * pow(log(n), b-1);};int iteration = 10;while (iteration --) {n -= (f(n) - t) / f1(n);}return n;}int main() {// inputint m; scanf("%d", &m);vector<int> as(m), bs(m);vector<double> ts(m);repeat (i,m) scanf("%d%d%lf", &as[i], &bs[i], &ts[i]);// solvearray<array<vector<int>, 10+1>, 10+1> xs = {};repeat (i,m) xs[as[i]][bs[i]].push_back(i);vector<double> n(m);repeat (a,10+1) {repeat (b,10+1) {if (a == 0) {for (int x : xs[a][b]) {n[x] = exp(pow(ts[x], 1.0/b));}} else if (b == 0) {for (int x : xs[a][b]) {n[x] = pow(ts[x], 1.0/a);}} else {whole(sort, xs[a][b], [&](int x, int y) {return ts[x] < ts[y];});double prev = 22027; // exp(10)repeat_reverse (i, int(xs[a][b].size())) {int x = xs[a][b][i];double t = ts[x];prev = n[x] = newton(a, b, t, prev);}}}}// outputrepeat (i,m) {printf("%.12lf\n", n[i]);}return 0;}