結果

問題 No.620 ぐるぐるぐるりん
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2017-12-21 15:25:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 264 ms / 1,000 ms
コード長 3,496 bytes
コンパイル時間 2,471 ms
コンパイル使用メモリ 75,044 KB
実行使用メモリ 60,932 KB
最終ジャッジ日時 2023-09-03 21:30:12
合計ジャッジ時間 7,574 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
53,012 KB
testcase_01 AC 86 ms
53,076 KB
testcase_02 AC 86 ms
53,008 KB
testcase_03 AC 88 ms
53,068 KB
testcase_04 AC 87 ms
53,060 KB
testcase_05 AC 86 ms
53,472 KB
testcase_06 AC 86 ms
53,100 KB
testcase_07 AC 89 ms
53,016 KB
testcase_08 AC 88 ms
53,508 KB
testcase_09 AC 88 ms
53,192 KB
testcase_10 AC 85 ms
52,964 KB
testcase_11 AC 85 ms
53,136 KB
testcase_12 AC 86 ms
52,924 KB
testcase_13 AC 87 ms
53,028 KB
testcase_14 AC 86 ms
53,020 KB
testcase_15 AC 87 ms
53,096 KB
testcase_16 AC 86 ms
53,024 KB
testcase_17 AC 86 ms
53,060 KB
testcase_18 AC 85 ms
52,972 KB
testcase_19 AC 87 ms
53,516 KB
testcase_20 AC 87 ms
53,408 KB
testcase_21 AC 86 ms
53,012 KB
testcase_22 AC 86 ms
53,172 KB
testcase_23 AC 86 ms
53,052 KB
testcase_24 AC 91 ms
53,020 KB
testcase_25 AC 88 ms
53,676 KB
testcase_26 AC 262 ms
60,932 KB
testcase_27 AC 92 ms
52,892 KB
testcase_28 AC 264 ms
59,904 KB
testcase_29 AC 250 ms
59,392 KB
testcase_30 AC 260 ms
59,552 KB
権限があれば一括ダウンロードができます

ソースコード

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);
    }
    C add(C o){
        return new C(x+o.x,y+o.y);
    }
    C conj(){
        return new C(x,-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];
        double abs=a.sq();
        double sum=0;
        double cur=1;
        for(int i=0;i<t;++i){
            sum+=cur;
            cur*=abs;
        }
        cur=1;
        C conjA=a.conj();
        //System.err.println("a="+a.x+" "+a.y+" inva="+inva.x+" "+inva.y);
        C zf=new C(1,0);
        C diffSum=diff.mul(new C(1.0/sum,0));
        for(int i=t-1;i>=0;--i){
            //System.err.println("cur="+cur+" sum="+sum);
            ans[i]=diffSum.mul(zf);
            zf=zf.mul(conjA);
        }
        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();
        C real=new C(1,0);
        for(int i=0;i<t;++i)
            real=real.mul(a).add(ans[i]);
        //System.err.println("p="+ p+" psum="+psum);
        //System.err.println("g=("+ gx+","+gy+") real=("+real.x+","+real.y+")");
    }
    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