8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1011ad9 + 7471b96 commit 16e959aCopy full SHA for 16e959a
0x15/solutions/1351.cpp
@@ -1,11 +1,31 @@
1
-// Authored by : BaaaaaaaaaaarkingDog
+// Authored by : scsc3204
2
// Co-authored by : -
3
-// http://boj.kr/****************
+// http://boj.kr/e81859b0268548ffad93a45b285dab49
4
#include <bits/stdc++.h>
5
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
+}
19
20
int main(void){
21
ios::sync_with_stdio(0);
22
cin.tie(0);
-
-}
23
24
+ cin >> n >> p >> q;
25
+ cout << solve(n);
26
27
+/*
28
+해시를 활용한 DP 구현입니다.
29
+재귀를 활용했으며,
30
+값을 이미 계산했다면 그 값을 반환합니다.
31
+*/
0 commit comments