-
Notifications
You must be signed in to change notification settings - Fork 1
/
1344_数列.cpp
41 lines (34 loc) · 1.09 KB
/
1344_数列.cpp
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
36
37
38
39
40
41
// Problem#: 1344
// Submission#: 2897604
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <iostream>
#include <algorithm>
using namespace std;
long long a[20];
long long t[2000];
int main() {
int k;
int n;
while(cin >> k >> n) {
for(int i = 0;i< 10;i ++) {
if(i == 0)a[i] = 1;
else a[i] = a[i - 1] * k;
// cout << a[i] << endl;
}
int alls = (1 << 10) - 1;
for(int i = 1;i <=alls;i ++) {
t[i] = 0;
//cout << i << ": ";
for(int j = 0;j < 10;j ++) {
if((i & (1 << j)) > 0) {
//cout << j << " ";
t[i] += a[j];
}
} //cout << endl;
}
sort(t + 1, t+ alls + 1);
cout << t[n] << endl;
}
}