FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
timus_cpp/task_1353.cpp at master · artbataev/timus_cpp · GitHub
artbataev
/
timus_cpp
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
2
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
timus_cpp
/
task_1353.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (27 loc) · 1.2 KB
Breadcrumbs
timus_cpp
/
task_1353.cpp
Copy path
File metadata and controls
35 lines (27 loc) · 1.2 KB
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
#
include
<
iostream
>
#
include
<
array
>
constexpr
int
MAX_SUM_DIGITS
=
81
;
constexpr
int
MAX_NUM_DIGITS
=
9
;
int
main
() {
std::ios::sync_with_stdio
(
false
);
std::array<std::array<
int
,
MAX_SUM_DIGITS
+
1
>,
MAX_NUM_DIGITS
+
1
> numdigis_sumdigits_count{};
int
required_sum_digits;
std::cin >> required_sum_digits;
for
(
int
sum_digits =
1
; sum_digits <= required_sum_digits; sum_digits++) {
if
(sum_digits <=
9
)
numdigis_sumdigits_count[
1
][sum_digits] =
1
;
for
(
int
num_digits =
2
; num_digits <=
MAX_NUM_DIGITS
; num_digits++)
for
(
int
additional_digit =
0
; additional_digit <=
9
; additional_digit++)
if
(sum_digits - additional_digit >=
0
) {
numdigis_sumdigits_count[num_digits][sum_digits] +=
numdigis_sumdigits_count[num_digits -
1
][sum_digits - additional_digit];
}
}
int
full_num_digits =
0
;
for
(
int
num_digits =
1
; num_digits <=
MAX_NUM_DIGITS
; num_digits++)
full_num_digits += numdigis_sumdigits_count[num_digits][required_sum_digits];
if
(required_sum_digits ==
1
)
//
count 10**9
full_num_digits++;
std::cout << full_num_digits;
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL