結果

問題 No.620 ぐるぐるぐるりん
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2017-12-20 00:27:17
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 3,162 bytes
コンパイル時間 2,390 ms
コンパイル使用メモリ 78,572 KB
実行使用メモリ 61,760 KB
最終ジャッジ日時 2023-08-22 07:19:52
合計ジャッジ時間 10,157 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 75 ms
52,864 KB
testcase_25 AC 83 ms
52,856 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

final class C{
    double x,y;
    C(double x,double y){
        this.x=x;this.y=y;
    }
    C mul(C o){
        return new C(x*o.x-y*o.y,x*o.y+y*o.x);
    }
    C div(C o){
        double f1=x*o.x+y*o.y;
        double f2=x*o.y-y*o.x;
        double s=o.sq();
        return new C(f1/s,f2/s);
    }
    C sub(C o){
        return new C(x-o.x,y-o.y);
    }
    double sq(){
        return x*x+y*y;
    }
}
class Main {
    static void solve(int t,double p,double omega,double v,double gx,double gy){
        C a=new C(1+v,omega);
        C g=new C(gx,gy);
        C init=new C(1,0);
        for(int i=0;i<t;++i)
            init=init.mul(a);
        C diff=g.sub(init);
        C[]ans=new C[t];
        for(int i=0;i<t;++i)ans[i]=new C(0,0);
        double abs=Math.sqrt(a.sq());
        double sum=0;
        double cur=1;
        for(int i=0;i<t;++i){
            sum+=cur;
            cur*=abs;
        }
        cur=1;
        C inva=new C(1,0).div(a);
        C zf=new C(1,0);
        for(int i=t-1;i>=0;--i){
            double f=cur/sum;
            ans[i]=diff.mul(new C(f,0)).mul(zf);
            cur*=abs;
            zf=zf.mul(inva);
        }
        for(int i=0;i<t;++i)
            out.println(ans[i].x+" "+ans[i].y);
        double psum=0;
        for(int i=0;i<t;++i)
            psum+=ans[i].sq();
        //System.err.println("p="+ p+" psum="+psum);
    }
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        for(int i=0;i<n;++i){
            int t=sc.nextInt();
            double p=sc.nextDouble();
            double omega=sc.nextDouble();
            double v=sc.nextDouble();
            double gx=sc.nextDouble();
            double gy=sc.nextDouble();
            solve(t,p,omega,v,gx,gy);
        }
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
0