結果
| 問題 |
No.620 ぐるぐるぐるりん
|
| コンテスト | |
| ユーザー |
夕叢霧香(ゆうむらきりか)
|
| 提出日時 | 2017-12-21 15:27:03 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 268 ms / 1,000 ms |
| コード長 | 2,890 bytes |
| コンパイル時間 | 2,708 ms |
| コンパイル使用メモリ | 79,884 KB |
| 実行使用メモリ | 47,252 KB |
| 最終ジャッジ日時 | 2024-06-13 02:09:22 |
| 合計ジャッジ時間 | 7,998 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
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;
}
}
}
夕叢霧香(ゆうむらきりか)