結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
52,892 KB
testcase_01 AC 85 ms
53,092 KB
testcase_02 AC 86 ms
54,036 KB
testcase_03 AC 85 ms
54,084 KB
testcase_04 AC 87 ms
54,164 KB
testcase_05 AC 86 ms
54,084 KB
testcase_06 AC 85 ms
52,916 KB
testcase_07 AC 86 ms
53,056 KB
testcase_08 AC 88 ms
52,936 KB
testcase_09 AC 87 ms
53,132 KB
testcase_10 AC 86 ms
53,084 KB
testcase_11 AC 86 ms
52,848 KB
testcase_12 AC 86 ms
52,964 KB
testcase_13 AC 87 ms
52,848 KB
testcase_14 AC 88 ms
53,180 KB
testcase_15 AC 85 ms
52,852 KB
testcase_16 AC 85 ms
53,000 KB
testcase_17 AC 88 ms
53,228 KB
testcase_18 AC 86 ms
54,372 KB
testcase_19 AC 90 ms
53,132 KB
testcase_20 AC 87 ms
53,100 KB
testcase_21 AC 88 ms
53,168 KB
testcase_22 AC 89 ms
53,296 KB
testcase_23 AC 85 ms
53,140 KB
testcase_24 AC 85 ms
52,976 KB
testcase_25 AC 87 ms
53,412 KB
testcase_26 AC 259 ms
59,032 KB
testcase_27 AC 88 ms
53,024 KB
testcase_28 AC 263 ms
60,260 KB
testcase_29 AC 260 ms
59,596 KB
testcase_30 AC 251 ms
59,492 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 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;
        }
        C conjA=a.conj();
        C zf=new C(1,0);
        C diffSum=diff.mul(new C(1.0/sum,0));
        for(int i=t-1;i>=0;--i){
            ans[i]=diffSum.mul(zf);
            zf=zf.mul(conjA);
        }
        for(int i=0;i<t;++i)
            out.println(ans[i].x+" "+ans[i].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