結果
問題 | No.620 ぐるぐるぐるりん |
ユーザー | rickytheta |
提出日時 | 2017-12-20 11:25:42 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,350 bytes |
コンパイル時間 | 2,473 ms |
コンパイル使用メモリ | 162,480 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-05-09 16:22:54 |
合計ジャッジ時間 | 3,755 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 1 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 1 ms
5,376 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 1 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | WA | - |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 1 ms
5,376 KB |
testcase_22 | AC | 1 ms
5,376 KB |
testcase_23 | AC | 1 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 1 ms
5,376 KB |
testcase_26 | WA | - |
testcase_27 | AC | 1 ms
5,376 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
コンパイルメッセージ
main.cpp: In function ‘void solve()’: main.cpp:65:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 65 | scanf("%d%lf%lf%lf%lf%lf",&t,&p,&omega,&v,&gx,&gy); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp: In function ‘int main()’: main.cpp:141:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 141 | scanf("%d",&n); | ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef int _loop_int; #define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i) #define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i) #define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i) #define DEBUG(x) cout<<#x<<": "<<x<<endl #define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl #define ALL(a) (a).begin(),(a).end() #define CHMIN(a,b) a=min((a),(b)) #define CHMAX(a,b) a=max((a),(b)) // mod const ll MOD = 1000000007ll; #define FIX(a) ((a)%MOD+MOD)%MOD // floating typedef double Real; const Real EPS = 1e-11; #define EQ0(x) (abs(x)<EPS) #define EQ(a,b) (abs(a-b)<EPS) typedef complex<Real> P; int t; double p; double omega, v; double gx, gy; int m; double B[2][35]; double b[35]; double A[2][2]; double Ainv[2][2]; double xy[2]; double z[35]; void putmat(){ REP(i,m)REP(j,m)printf("%.2f%c",A[i][j],j==m-1?'\n':' '); printf("z: "); REP(i,m)printf("%.2f%c",z[i],i==m-1?'\n':' '); } // void SOR(){ // REP(_,100){ // REP(i,m){ // double sum = b[i]; // REP(j,m)sum -= A[i][j] * z[j]; // z[i] = z[i] + sum / A[i][i]; // } // REP(i,m)printf("%.4f ",z[i]);puts(""); // } // } void solve(){ scanf("%d%lf%lf%lf%lf%lf",&t,&p,&omega,&v,&gx,&gy); vector<double> vx, vy; REP(i,t){ double x = 1.0, y = 0.0; FOR(j,i+1,t){ double nx = x - omega*y + v*x; double ny = y + omega*x + v*y; x = nx; y = ny; } vx.push_back(x); vy.push_back(y); x = 0.0, y = 1.0; FOR(j,i+1,t){ double nx = x - omega*y + v*x; double ny = y + omega*x + v*y; x = nx; y = ny; } vx.push_back(x); vy.push_back(y); } double sx = 1.0, sy = 0.0; REP(i,t){ double nx = sx - omega*sy + v*sx; double ny = sy + omega*sx + v*sy; sx = nx; sy = ny; } double ax = gx-sx, ay = gy-sy; // problem. sum p_i vx_i == ax // sum p_i vy_i == ay // sum p_i^2 <= p // minimize. sum p_i^2 // subject to. sum p_i vx_i == ax // sum p_i vy_i == ay m = 2*t; // Bx = b REP(i,2)REP(j,m)B[i][j] = 0.0; REP(i,m)B[0][i] = vx[i]; REP(i,m)B[1][i] = vy[i]; b[0] = ax; b[1] = ay; // A = BB^T REP(i,2)REP(j,2)A[i][j] = 0.0; REP(i,2)REP(j,2)REP(k,m)A[i][j] += B[i][k] * B[j][k]; // Ay = b double detA = A[0][0] * A[1][1] - A[0][1] * A[1][0]; Ainv[0][0] = A[1][1] / detA; Ainv[0][1] = -A[0][1] / detA; Ainv[1][0] = -A[1][0] / detA; Ainv[1][1] = A[0][0] / detA; // y = Ainv b xy[0] = Ainv[0][0] * b[0] + Ainv[0][1] * b[1]; xy[1] = Ainv[1][0] * b[0] + Ainv[1][1] * b[1]; // z = A^T y REP(i,m)z[i] = B[0][i] * xy[0] + B[1][i] * xy[1]; // simulate double simx = 1.0, simy = 0.0; double power = 0.0; REP(i,t){ double ux = z[2*i], uy = z[2*i+1]; printf("%.9f %.9f\n", ux, uy); power += ux*ux + uy*uy; double nx = simx - omega*simy + v*simx + ux; double ny = simy + omega*simx + v*simy + uy; simx = nx; simy = ny; } // printf("(%.5f, %.5f) is goal, (%.5f, %.5f) is answer, power is %.5f(<= %.5f)\n", gx, gy, simx, simy, power, p); } int main(){ int n; scanf("%d",&n); while(n--)solve(); return 0; }