8000 Create 1351.cpp · dkim-coder/basic-algo-lecture@2303e9e · GitHub
[go: up one dir, main page]

Skip to content

Commit 2303e9e

Browse files
Create 1351.cpp
1 parent be69069 commit 2303e9e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Appendix E/1351.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// http://boj.kr/5a8c26a75fd7433da8b814fc477b0317
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
5+
using ll = long long;
6+
ll n, p, q;
7+
map<ll, ll> a;
8+
9+
ll go(ll x){
10+
if(a[x] != 0)
11+
return a[x];
12+
if(x == 0)
13+
return a[x] = 1;
14+
return a[x] = go(x/p) + go(x/q);
15+
}
16+
17+
int main(void) {
18+
ios::sync_with_stdio(0);
19+
cin.tie(0);
20+
21+
cin >> n >> p >> q;
22+
cout << go(n);
23+
}

0 commit comments

Comments
 (0)
0