Submission #123374


Source Code Expand

Copy
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		int r = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int d = sc.nextInt();
		int l = sc.nextInt();
		calc(r, c, x, y, d, l);
	}
	public void calc(int r, int c, int x, int y, int d, int l) {
		BigInteger c1 = keisan(BigInteger.valueOf(x*y), BigInteger.valueOf(x*y - d - l));
		BigInteger c2 = keisan(BigInteger.valueOf((x-1)*y), BigInteger.valueOf((x-1)*y-d-l));
		BigInteger c3 = keisan(BigInteger.valueOf((x-2)*y), BigInteger.valueOf((x-2)*y-d-l));
		BigInteger c4 = keisan(BigInteger.valueOf(x*(y-1)), BigInteger.valueOf(x*(y-1)-d-l));
		BigInteger c5 = keisan(BigInteger.valueOf(x*(y-2)), BigInteger.valueOf(x*(y-2)-d-l));
		BigInteger c6 = keisan(BigInteger.valueOf((x-2)*(y-1)), BigInteger.valueOf((x-2)*(y-1)-d-l));
		BigInteger c7 = keisan(BigInteger.valueOf((x-1)*(y-2)), BigInteger.valueOf((x-1)*(y-2)-d-l));
		BigInteger c8 = keisan(BigInteger.valueOf((x-1)*(y-1)), BigInteger.valueOf((x-1)*(y-1)-d-l));
		BigInteger c9 = keisan(BigInteger.valueOf((x-2)*(y-2)), BigInteger.valueOf((x-2)*(y-2)-d-l));
		//BigInteger c4 = keisan(BigInteger.valueOf(x*y-x-y+1), BigInteger.valueOf(x*y-x-y+1-d-l));
		
		
		BigInteger dd = kaijou(d);
		BigInteger ll = kaijou(l);
		
		BigInteger a1 = c1;
		
		a1 = a1.subtract(c2);
		a1 = a1.subtract(c2);
		
		a1 = a1.add(c3);
		
		a1 = a1.subtract(c4);
		a1 = a1.subtract(c4);
		
		a1 = a1.add(c5);
		
		a1 = a1.subtract(c6);
		a1 = a1.subtract(c6);
		
		a1 = a1.subtract(c7);
		a1 = a1.subtract(c7);
		
		a1 = a1.add(c8);
		a1 = a1.add(c8);
		a1 = a1.add(c8);
		a1 = a1.add(c8);
		
		a1 = a1.add(c9);
		
		a1 = a1.divide(dd);
		a1 = a1.divide(ll);
				
		BigInteger kk = BigInteger.valueOf(r-x+1).multiply(BigInteger.valueOf(c-y+1));
		
		a1 = a1.multiply(kk);
		
		System.out.println(a1.remainder(chousei));
	}
	BigInteger chousei = new BigInteger("1000000007");
	public BigInteger keisan(BigInteger t1, BigInteger t2){
		BigInteger ans = new BigInteger("1");
		while(t1.compareTo(t2) > 0){
			ans = ans.multiply(t1);
			t1 = t1.subtract(new BigInteger("1"));
		}
		if(ans.compareTo(new BigInteger("0")) < 0) return new BigInteger("0");
		return ans;
	}

	public BigInteger kaijou(int k){
		BigInteger ans = new BigInteger("1");
		while(k > 0){
			ans = ans.multiply(BigInteger.valueOf(k));
			k = k -1;
		}
		return ans;
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Submission Info

Submission Time
Task D - AtCoder社の冬
User wapiko
Language Java (OpenJDK 1.7.0)
Score 0
Code Size 2635 Byte
Status WA
Exec Time 554 ms
Memory 31408 KB

Judge Result

Set Name sub All
Score / Max Score 0 / 100 0 / 1
Status
AC × 21
WA × 4
AC × 46
WA × 6
Set Name Test Cases
sub 00_sample_01E.txt, 00_sample_02E.txt, 00_sample_03E.txt, test_03E.txt, test_04E.txt, test_07E.txt, test_08E.txt, test_11E.txt, test_12E.txt, test_15E.txt, test_16E.txt, test_19E.txt, test_20E.txt, test_23E.txt, test_24E.txt, test_27E.txt, test_28E.txt, test_31E.txt, test_32E.txt, test_36E.txt, test_37E.txt, test_38E.txt, test_39E.txt, test_45E.txt, test_47E.txt
All 00_sample_01E.txt, 00_sample_02E.txt, 00_sample_03E.txt, 00_sample_04.txt, test_01.txt, test_02.txt, test_03E.txt, test_04E.txt, test_05.txt, test_06.txt, test_07E.txt, test_08E.txt, test_09.txt, test_10.txt, test_11E.txt, test_12E.txt, test_13.txt, test_14.txt, test_15E.txt, test_16E.txt, test_17.txt, test_18.txt, test_19E.txt, test_20E.txt, test_21.txt, test_22.txt, test_23E.txt, test_24E.txt, test_25.txt, test_26.txt, test_27E.txt, test_28E.txt, test_29.txt, test_30.txt, test_31E.txt, test_32E.txt, test_33.txt, test_34.txt, test_35.txt, test_36E.txt, test_37E.txt, test_38E.txt, test_39E.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45E.txt, test_46.txt, test_47E.txt, test_48.txt
Case Name Status Exec Time Memory
00_sample_01E.txt AC 527 ms 23472 KB
00_sample_02E.txt AC 466 ms 23476 KB
00_sample_03E.txt AC 497 ms 24364 KB
00_sample_04.txt AC 503 ms 24884 KB
test_01.txt AC 455 ms 23604 KB
test_02.txt AC 458 ms 23472 KB
test_03E.txt AC 470 ms 23344 KB
test_04E.txt AC 507 ms 25652 KB
test_05.txt AC 460 ms 23472 KB
test_06.txt AC 490 ms 24244 KB
test_07E.txt AC 470 ms 23732 KB
test_08E.txt AC 479 ms 24328 KB
test_09.txt AC 458 ms 23596 KB
test_10.txt AC 469 ms 24112 KB
test_11E.txt AC 482 ms 24336 KB
test_12E.txt AC 498 ms 25268 KB
test_13.txt AC 455 ms 23592 KB
test_14.txt AC 550 ms 31408 KB
test_15E.txt AC 503 ms 26160 KB
test_16E.txt AC 546 ms 31272 KB
test_17.txt AC 456 ms 23452 KB
test_18.txt AC 450 ms 23460 KB
test_19E.txt AC 455 ms 23600 KB
test_20E.txt AC 462 ms 23600 KB
test_21.txt AC 455 ms 23468 KB
test_22.txt AC 475 ms 24624 KB
test_23E.txt WA 454 ms 23472 KB
test_24E.txt AC 521 ms 28848 KB
test_25.txt AC 461 ms 24116 KB
test_26.txt AC 452 ms 23572 KB
test_27E.txt AC 482 ms 25392 KB
test_28E.txt AC 503 ms 27048 KB
test_29.txt AC 465 ms 24116 KB
test_30.txt AC 489 ms 25132 KB
test_31E.txt AC 487 ms 24496 KB
test_32E.txt AC 554 ms 31140 KB
test_33.txt WA 457 ms 23572 KB
test_34.txt AC 493 ms 23984 KB
test_35.txt AC 460 ms 23444 KB
test_36E.txt WA 471 ms 23596 KB
test_37E.txt AC 460 ms 23600 KB
test_38E.txt AC 491 ms 23464 KB
test_39E.txt WA 470 ms 23444 KB
test_40.txt AC 485 ms 23980 KB
test_41.txt AC 465 ms 23468 KB
test_42.txt AC 467 ms 23704 KB
test_43.txt AC 464 ms 23564 KB
test_44.txt AC 467 ms 23588 KB
test_45E.txt WA 458 ms 23476 KB
test_46.txt AC 463 ms 23464 KB
test_47E.txt AC 464 ms 23476 KB
test_48.txt WA 466 ms 23596 KB