結果
問題 | No.764 浮動点 |
ユーザー | 37zigen |
提出日時 | 2018-12-01 19:47:38 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 280 ms / 1,500 ms |
コード長 | 3,531 bytes |
コンパイル時間 | 2,368 ms |
コンパイル使用メモリ | 78,872 KB |
実行使用メモリ | 45,780 KB |
最終ジャッジ日時 | 2024-06-27 00:02:23 |
合計ジャッジ時間 | 9,748 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 118 ms
41,184 KB |
testcase_01 | AC | 118 ms
41,320 KB |
testcase_02 | AC | 122 ms
41,592 KB |
testcase_03 | AC | 183 ms
41,896 KB |
testcase_04 | AC | 246 ms
42,696 KB |
testcase_05 | AC | 186 ms
41,780 KB |
testcase_06 | AC | 249 ms
43,028 KB |
testcase_07 | AC | 182 ms
41,740 KB |
testcase_08 | AC | 242 ms
42,968 KB |
testcase_09 | AC | 204 ms
41,912 KB |
testcase_10 | AC | 268 ms
43,692 KB |
testcase_11 | AC | 212 ms
41,816 KB |
testcase_12 | AC | 279 ms
45,184 KB |
testcase_13 | AC | 270 ms
45,228 KB |
testcase_14 | AC | 273 ms
44,248 KB |
testcase_15 | AC | 269 ms
44,296 KB |
testcase_16 | AC | 269 ms
44,888 KB |
testcase_17 | AC | 275 ms
44,916 KB |
testcase_18 | AC | 260 ms
44,172 KB |
testcase_19 | AC | 267 ms
45,240 KB |
testcase_20 | AC | 271 ms
45,776 KB |
testcase_21 | AC | 273 ms
44,148 KB |
testcase_22 | AC | 279 ms
45,780 KB |
testcase_23 | AC | 276 ms
44,996 KB |
testcase_24 | AC | 280 ms
45,116 KB |
testcase_25 | AC | 145 ms
41,688 KB |
ソースコード
import java.util.*; import java.io.*; import java.math.*; class Main{ public static void main(String[] args){ new Main().run(); } void run(){ Scanner sc=new Scanner(); int N=sc.nextInt(); double[] L=new double[N+2]; for(int i=0;i<=N+1;++i){ L[i]=sc.nextInt(); } double[] Ri1=new double[N+2]; double[] Ro1=new double[N+2]; double[] Ri2=new double[N+2]; double[] Ro2=new double[N+2]; for(int i=1;i<=N;++i){ Ro1[i]=Ro1[i-1]+L[i]; } Ri1[1]=Ro1[1]; for(int i=2;i<=N;++i){ Ri1[i]=abs(Ri1[i-1],Ro1[i-1],L[i]); } for(int i=N;i>=1;--i){ Ro2[i]=Ro2[i+1]+L[i+1]; } Ri2[N]=Ro2[N]; for(int i=N-1;i>=1;--i){ Ri2[i]=abs(Ri2[i+1],Ro2[i+1],L[i+1]); } for(int i=1;i<=N;++i){ System.out.println(String.format("%.20f",solve(Ro1[i],Ri1[i],Ro2[i],Ri2[i],L[0]))); } } double solve(double Ro1,double Ri1,double Ro2,double Ri2,double L){ return f(Ro1,Ro2,L)-f(Ro1,Ri2,L)-f(Ri1,Ro2,L)+f(Ri1,Ri2,L); } double abs(double a,double b,double d){ if(a<=d&&d<=b)return 0; return Math.min(Math.abs(d-a),Math.abs(d-b)); } double f(double a,double b,double L){ if(L>=a+b)return 0; if(b>=a+L)return a*a*Math.PI; if(a>=b+L)return b*b*Math.PI; double x=0.5*L+(a*a-b*b)/(2*L); double y=Math.sqrt(a*a-x*x); double ang1=Math.atan2(y,x); double ang2=Math.atan2(y,L-x); if(ang1<0)ang1+=Math.PI; if(ang2<0)ang2+=Math.PI; return g(2*ang1,a)+g(2*ang2,b); } double g(double ang,double r){ return 0.5*r*r*(ang - Math.sin(ang)); } void tr(Object...o){ System.out.println(Arrays.deepToString(o)); } } class Scanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; }else{ ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;} private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;} private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;} public boolean hasNext() { skipUnprintable(); return hasNextByte();} public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while(isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while(true){ if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; }else if(b == -1 || !isPrintableChar(b)){ return minus ? -n : n; }else{ throw new NumberFormatException(); } b = readByte(); } } public int nextInt(){ return (int)nextLong(); } }