8000 update: 0x15 1351.cpp · sihyeon-kim/basic-algo-lecture@edc20f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit edc20f7

Browse files
committed
update: 0x15 1351.cpp
1 parent 640e385 commit edc20f7

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

0x15/solutions/1351.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
1-
// Authored by : BaaaaaaaaaaarkingDog
1+
// Authored by : scsc3204
22
// Co-authored by : -
3-
// http://boj.kr/****************
3+
// http://boj.kr/e81859b0268548ffad93a45b285dab49
44
#include <bits/stdc++.h>
55
using namespace std;
6+
typedef long long ll;
7+
8+
ll n;
9+
int p, q;
10+
unordered_map<ll, ll> um;
11+
12+
ll solve(ll x) {
13+
if(x == 0) return 1;
14+
if(um[x]) return um[x];
15+
16+
um[x] = solve(x/p) + solve(x/q);
17+
return um[x];
18+
}
619

720
int main(void){
821
ios::sync_with_stdio(0);
922
cin.tie(0);
10-
11-
}
23+
24+
cin >> n >> p >> q;
25+
cout << solve(n);
26+
}
27+
/*
28+
해시를 활용한 DP문제입니다.
29+
30+
*/

0 commit comments

Comments
 (0)
0