Submission #1690959
Source Code Expand
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long w=sc.nextLong(),h=sc.nextLong(); long buf; long ans=1; if(w<h){ buf=w; w=h; h=buf; } w-=1;h-=1; long beki=(long)Math.pow(10, 9)+7; for(long i=0;i<h;i++){ //System.out.println(w+h-i+" "+(i+1)); ans=ans*(w+h-i)%beki; ans*=calc(i+1,beki-2,beki); ans%=beki; } System.out.println(ans); } static long calc(long a,long b,long p){ if(b==0){ return 1; } else if(b%2==0){ long d=calc(a,b/2,p); return (d*d)%p; }else{ return (a*calc(a,b-1,p))%p; } } }
Submission Info
Submission Time | |
---|---|
Task | C - 経路 |
User | ri2112 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 101 |
Code Size | 677 Byte |
Status | AC |
Exec Time | 174 ms |
Memory | 23636 KB |
Judge Result
Set Name | Sample | Dataset1 | Dataset2 | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 50 / 50 | 50 / 50 | 1 / 1 | ||||||||
Status |
|
|
|
|
Set Name | Test Cases |
---|---|
Sample | s0.txt, s1.txt |
Dataset1 | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, s0.txt |
Dataset2 | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, s0.txt, s1.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, s0.txt, s1.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 98 ms | 19924 KB |
001.txt | AC | 92 ms | 21716 KB |
002.txt | AC | 90 ms | 23636 KB |
003.txt | AC | 91 ms | 21716 KB |
004.txt | AC | 91 ms | 16980 KB |
005.txt | AC | 93 ms | 21844 KB |
006.txt | AC | 92 ms | 19796 KB |
007.txt | AC | 90 ms | 21844 KB |
008.txt | AC | 89 ms | 19924 KB |
009.txt | AC | 92 ms | 20560 KB |
010.txt | AC | 92 ms | 18900 KB |
011.txt | AC | 93 ms | 19156 KB |
012.txt | AC | 91 ms | 18640 KB |
013.txt | AC | 92 ms | 18900 KB |
014.txt | AC | 109 ms | 19924 KB |
015.txt | AC | 93 ms | 21716 KB |
016.txt | AC | 93 ms | 20948 KB |
017.txt | AC | 92 ms | 19924 KB |
018.txt | AC | 93 ms | 20564 KB |
019.txt | AC | 104 ms | 21076 KB |
020.txt | AC | 103 ms | 22736 KB |
021.txt | AC | 95 ms | 17748 KB |
022.txt | AC | 153 ms | 19156 KB |
023.txt | AC | 141 ms | 21716 KB |
024.txt | AC | 134 ms | 17748 KB |
025.txt | AC | 95 ms | 19668 KB |
026.txt | AC | 102 ms | 21716 KB |
027.txt | AC | 133 ms | 21588 KB |
028.txt | AC | 144 ms | 20692 KB |
029.txt | AC | 117 ms | 19924 KB |
030.txt | AC | 135 ms | 21460 KB |
031.txt | AC | 123 ms | 18644 KB |
032.txt | AC | 174 ms | 20560 KB |
s0.txt | AC | 90 ms | 19924 KB |
s1.txt | AC | 91 ms | 18900 KB |