-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteleport.cpp
68 lines (57 loc) · 1.31 KB
/
teleport.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <set>
#include <sstream>
#include <stdlib.h>
#include <map>
#include <queue>
#include <assert.h>
#include <deque>
#include <string.h>
using namespace std;
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
typedef long long int64;
typedef vector <int64> vi;
typedef vector <vi> vvi;
// if a == 2:
// return mod(2 * c + 1 + (c + 1) * b), False
// for i in xrange(start, end):
// dp[i] = mod( dp[i - 1] * (c + 1) + 1 + 2 * c )
const int64 MX = 32768;
const int64 MOD = 32768;
int64 mod(int64 v) {
return ((v % MOD) + MOD) % MOD;
}
int64 f2(int64 c) {
return mod(2 * c + 1 + (c + 1) * c);
}
void solution() {
for (int c = 1; c < MX; ++c) {
vi dp(MX, 0);
dp[0] = f2(c);
for (int i = 1; i < MX; ++i) {
dp[i] = mod( dp[i - 1] * (c + 1) + 1 + 2 * c );
}
int64 value = dp[ dp[c] ];
cout << "dp[ " << c << " ] = " << value << endl;
if (value == 6) {
cout << "Found ans: " << value << endl;
return;
}
}
}
int main () {
//freopen("", "rt", stdin);
//freopen("", "wt", stdout);
//std::ios::sync_with_stdio(false);
solution();
return 0;
}