-
Notifications
You must be signed in to change notification settings - Fork 126
/
Copy pathUVa1591.cc
43 lines (41 loc) · 992 Bytes
/
UVa1591.cc
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
42
43
// UVa1591 Data Mining
// 陈锋
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <climits>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>
using namespace std;
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
typedef long long LL;
int main() {
LL N, SP, SQ;
auto f = [](LL x, int a, int b){
return (x + (x<<a)) >> b;
};
while(scanf("%lld%lld%lld", &N, &SP, &SQ) == 3){
int A = 64, B = 64;
LL K = LLONG_MAX;
_rep(a, 0, 31) _rep(b, 0, 31){
if(f(SP,a,b) < SQ) continue;
LL k = f(SP*(N-1),a,b) + SQ;
if(k < K) K = k, A = a, B = b;
}
printf("%lld %d %d\n", K, A, B);
}
return 0;
}
// 2136321 2959 Data Mining Accepted C++11 0.003 2017-03-05 14:30:20