結果
問題 | No.764 浮動点 |
ユーザー | 37zigen |
提出日時 | 2018-12-01 19:47:38 |
言語 | Java19 (openjdk 21) |
結果 |
AC
|
実行時間 | 298 ms / 1,500 ms |
コード長 | 3,531 bytes |
コンパイル時間 | 4,157 ms |
コンパイル使用メモリ | 74,244 KB |
実行使用メモリ | 58,944 KB |
最終ジャッジ日時 | 2023-09-09 06:53:17 |
合計ジャッジ時間 | 10,180 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 116 ms
55,808 KB |
testcase_01 | AC | 116 ms
55,572 KB |
testcase_02 | AC | 119 ms
55,652 KB |
testcase_03 | AC | 184 ms
56,092 KB |
testcase_04 | AC | 238 ms
56,716 KB |
testcase_05 | AC | 184 ms
56,372 KB |
testcase_06 | AC | 251 ms
56,360 KB |
testcase_07 | AC | 188 ms
56,184 KB |
testcase_08 | AC | 250 ms
56,620 KB |
testcase_09 | AC | 210 ms
56,460 KB |
testcase_10 | AC | 270 ms
57,420 KB |
testcase_11 | AC | 199 ms
56,400 KB |
testcase_12 | AC | 281 ms
57,332 KB |
testcase_13 | AC | 298 ms
57,488 KB |
testcase_14 | AC | 281 ms
57,280 KB |
testcase_15 | AC | 282 ms
57,736 KB |
testcase_16 | AC | 282 ms
57,192 KB |
testcase_17 | AC | 273 ms
58,944 KB |
testcase_18 | AC | 270 ms
58,596 KB |
testcase_19 | AC | 261 ms
57,940 KB |
testcase_20 | AC | 284 ms
57,760 KB |
testcase_21 | AC | 281 ms
57,140 KB |
testcase_22 | AC | 284 ms
57,512 KB |
testcase_23 | AC | 284 ms
57,828 KB |
testcase_24 | AC | 282 ms
57,352 KB |
testcase_25 | AC | 143 ms
55,860 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(); } }