FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Competitive-Programming/Algorithms/NcR.java at master · joney000/Java-Competitive-Programming · GitHub
joney000
/
Java-Competitive-Programming
Public
Notifications
You must be signed in to change notification settings
Fork
30
Star
123
Code
Issues
0
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Competitive-Programming
/
Algorithms
/
NcR.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
35 lines (27 loc) · 886 Bytes
Breadcrumbs
Java-Competitive-Programming
/
Algorithms
/
NcR.java
Copy path
File metadata and controls
executable file
·
35 lines (27 loc) · 886 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import
java
.
io
.*;
import
java
.
util
.*;
import
java
.
lang
.*;
class
DPnCr
{
public
static
void
main
(
String
[]
ss
)
throws
Exception
{
BufferedReader
br
=
new
BufferedReader
(
new
InputStreamReader
(
System
.
in
));
BufferedWriter
out
=
new
BufferedWriter
(
new
OutputStreamWriter
(
System
.
out
));
int
tests
=
Integer
.
parseInt
(
br
.
readLine
());
for
(
int
t
=
0
;
t
<
tests
;
t
++){
int
n
=
Integer
.
parseInt
(
br
.
readLine
());
int
[]
num
=
new
int
[
n
];
String
[]
s
=
br
.
readLine
().
split
(
" "
);
for
(
int
i
=
0
;
i
<
n
;
i
++){
num
[
i
]=
Integer
.
parseInt
(
s
[
i
]);
}
long
[][]
c
=
new
long
[
20
+
1
][
20
+
1
];
//n=20;c(20,r)
for
(
int
i
=
0
;
i
<=
20
;
i
++){
c
[
i
][
i
]=
1
;
c
[
i
][
0
]=
c
[
0
][
i
]=
0
;
c
[
i
][
1
]=
i
;}
for
(
int
j
=
2
;
j
<
20
;
j
++){
for
(
int
i
=
j
+
1
;
i
<=
20
;
i
++){
c
[
i
][
j
]=
c
[
i
-
1
][
j
]+
c
[
i
-
1
][
j
-
1
];
}
}
for
(
int
i
=
0
;
i
<
n
;
i
++){
out
.
write
(
""
+
c
[
20
][
num
[
i
]]+
"
\n
"
);
out
.
flush
();}
}
}
}
Back
|
FazBrowse Home
|
New Git URL