Submission #188220
Source Code Expand
import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int D = sc.nextInt(); int x = sc.nextInt(); int y = sc.nextInt(); if (Math.abs(x)%D !=0 || Math.abs(y)%D != 0) { System.out.println(0); return; } x = Math.abs(x)/D; y = Math.abs(y)/D; if (x+y>n || (n+x+y)%2==1) { System.out.println(0); return; } BigInteger[] fact = new BigInteger[1001]; fact[0] = BigInteger.ONE; for(int i=1;i<=1000;i++) { fact[i] = fact[i-1].multiply(BigInteger.valueOf(i)); } BigInteger sum = BigInteger.ZERO; BigDecimal pow = BigDecimal.valueOf(Math.pow(4, n)); for(int a=x;(n+x+y)/2-a>=y;a++) { int b = a-x; int c = (n+x+y)/2-a; int d = c-y; sum = sum.add(fact[n].divide(fact[a]).divide(fact[b]).divide(fact[c]).divide(fact[d])); } double ans = new BigDecimal(sum).setScale(10).divide(pow,RoundingMode.HALF_UP).doubleValue(); System.out.println(ans); } }
Submission Info
Submission Time | |
---|---|
Task | A - 来月は何月? |
User | piroz95 |
Language | Java (OpenJDK 1.7.0) |
Score | 0 |
Code Size | 1143 Byte |
Status | RE |
Exec Time | 465 ms |
Memory | 23348 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 0 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | test_1.txt, test_10.txt, test_11.txt, test_12.txt, test_2.txt, test_3.txt, test_4.txt, test_5.txt, test_6.txt, test_7.txt, test_8.txt, test_9.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
test_1.txt | RE | 438 ms | 23216 KB |
test_10.txt | RE | 431 ms | 23340 KB |
test_11.txt | RE | 437 ms | 23216 KB |
test_12.txt | RE | 434 ms | 23216 KB |
test_2.txt | RE | 439 ms | 23228 KB |
test_3.txt | RE | 449 ms | 23348 KB |
test_4.txt | RE | 460 ms | 23348 KB |
test_5.txt | RE | 465 ms | 23344 KB |
test_6.txt | RE | 451 ms | 23100 KB |
test_7.txt | RE | 452 ms | 23224 KB |
test_8.txt | RE | 439 ms | 23344 KB |
test_9.txt | RE | 444 ms | 23348 KB |