Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- string triToPI(int x, int n) {
- string str;
- for (int i = 0; i < n; i++) {
- if (x % 3 == 2) str.push_back('-');
- else {
- str.push_back('0' + (x % 3));
- }
- x /= 3;
- }
- return move(str);
- }
- constexpr int MAXN = 400000000;
- bool used[2][MAXN];
- bool ok[MAXN];
- void qm(vector<int> arr, int n) {
- for (int x: arr) {
- int cnt = __builtin_popcount(x);
- int tri = 0;
- for (int i = 0; i < n; i++) {
- tri *= 3;
- tri += (x % 2);
- x /= 2;
- }
- used[0][tri] = 1;
- }
- puts("A");
- vector<int> PI;
- bool ismodify = true;
- int round = 1;
- while (ismodify) {
- printf("Round %d:\n", round++);
- memset(used[1], 0, sizeof(used[1]));
- memset(ok, 0, sizeof(ok));
- ismodify = false;
- for (int i = 0; i < MAXN; i++) {
- if (used[0][i] == 0) continue;
- //cout << triToPI(i, n) << endl;
- int tribase = 1;
- int cur = i;
- for (int pos = 0; pos < n; pos++, cur /= 3, tribase *= 3) {
- if (cur % 3) continue;
- int tmp = i + tribase;
- if (used[0][tmp] == 0) continue;
- ok[i] = true;
- ok[tmp] = true;
- //cout << triToPI(A, n) << ", " << triToPI(tmp, n);
- tmp = i + tribase * 2;
- used[1][tmp] = true;
- ismodify = true;
- }
- }
- for (int i = 0; i < MAXN; i++) {
- if (used[0][i] && !ok[i]) {
- PI.push_back(i);
- }
- }
- memcpy(used[0], used[1], sizeof(used[1]));
- }
- for (int x: PI) {
- cout << "PI: " << triToPI(x, n) << endl;
- }
- }
- int main() {
- vector<int> tmp;// = {0, 1, 3};
- int n = 18;
- for (int i = 0 ; i < (1 << n); i++) {
- tmp.push_back(i);
- }
- qm(tmp, n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement