Submission #122940


Source Code Expand

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

public class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int r=sc.nextInt();
		int c=sc.nextInt();
		int x=sc.nextInt();
		int y=sc.nextInt();
		int d=sc.nextInt();
		int l=sc.nextInt();
		//長方形の取り方
		int num1=(r-x+1)*(c-y+1);
		//長方形中のパターン
		//計算の手間を減らす
		BigInteger pattern;
		if(d+l==x*y){
			if(d<l){
				//計算内容:(l+1)*(l+2)*~(l+d)/d!
				 pattern=calculateFact(l+1,d).divide(calculateFact(1,d));
			}else{
				//計算内容:(d+1)*(d+2)*~(d+l)/l!
				 pattern=calculateFact(d+1,l).divide(calculateFact(1,l));
			}
			pattern=pattern.multiply(new BigInteger(Integer.toString(num1)));
			System.out.println(pattern.remainder(new BigInteger("1000000007")));
		}else{
			pattern=calculateFact(x*y-d-l+1,d+l).divide(calculateFact(1,d));
			pattern=pattern.divide(calculateFact(1,l));
			pattern.multiply(new BigInteger(Integer.toString(num1)));
			System.out.println(pattern.remainder(new BigInteger("1000000007")));
		}
		
		
	}
	private static BigInteger calculateFact(int begin,int num){
		BigInteger result=BigInteger.ONE;
		BigInteger time_num=new BigInteger(Integer.toString(begin));
		for(int i=0;i<num;i++){
			result=result.multiply(time_num);
			time_num=time_num.add(BigInteger.ONE);
		}
		return result;
		
	}
}

Submission Info

Submission Time
Task D - AtCoder社の冬
User teamhime
Language Java (OpenJDK 1.7.0)
Score 100
Code Size 1424 Byte
Status WA
Exec Time 407 ms
Memory 23732 KB

Judge Result

Set Name sub All
Score / Max Score 100 / 100 0 / 1
Status
AC × 25
AC × 26
WA × 26
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 407 ms 21812 KB
00_sample_02E.txt AC 380 ms 22048 KB
00_sample_03E.txt AC 379 ms 21936 KB
00_sample_04.txt WA 377 ms 22488 KB
test_01.txt WA 373 ms 22052 KB
test_02.txt WA 373 ms 21936 KB
test_03E.txt AC 381 ms 21976 KB
test_04E.txt AC 378 ms 21932 KB
test_05.txt WA 374 ms 21928 KB
test_06.txt WA 376 ms 21924 KB
test_07E.txt AC 372 ms 22068 KB
test_08E.txt AC 377 ms 21924 KB
test_09.txt WA 381 ms 21932 KB
test_10.txt WA 376 ms 22056 KB
test_11E.txt AC 380 ms 21940 KB
test_12E.txt AC 373 ms 22068 KB
test_13.txt WA 368 ms 21936 KB
test_14.txt AC 388 ms 23732 KB
test_15E.txt AC 376 ms 21924 KB
test_16E.txt AC 379 ms 21936 KB
test_17.txt WA 376 ms 21816 KB
test_18.txt WA 372 ms 21924 KB
test_19E.txt AC 376 ms 21912 KB
test_20E.txt AC 378 ms 21796 KB
test_21.txt WA 375 ms 21940 KB
test_22.txt WA 387 ms 22320 KB
test_23E.txt AC 375 ms 21916 KB
test_24E.txt AC 375 ms 21904 KB
test_25.txt WA 378 ms 22068 KB
test_26.txt WA 375 ms 21936 KB
test_27E.txt AC 373 ms 22068 KB
test_28E.txt AC 376 ms 21808 KB
test_29.txt WA 377 ms 22064 KB
test_30.txt WA 380 ms 22308 KB
test_31E.txt AC 374 ms 21936 KB
test_32E.txt AC 373 ms 21928 KB
test_33.txt WA 374 ms 21940 KB
test_34.txt WA 378 ms 21940 KB
test_35.txt WA 379 ms 21932 KB
test_36E.txt AC 377 ms 22064 KB
test_37E.txt AC 372 ms 21936 KB
test_38E.txt AC 375 ms 21936 KB
test_39E.txt AC 381 ms 21936 KB
test_40.txt WA 385 ms 21920 KB
test_41.txt WA 387 ms 21972 KB
test_42.txt WA 388 ms 21936 KB
test_43.txt WA 405 ms 21936 KB
test_44.txt WA 398 ms 21924 KB
test_45E.txt AC 380 ms 21920 KB
test_46.txt WA 381 ms 21808 KB
test_47E.txt AC 380 ms 22016 KB
test_48.txt WA 387 ms 21936 KB