Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma comment(linker,"/STACK:64000000")
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <vector>
- #include <string>
- #include <sstream>
- #include <cmath>
- #include <map>
- #include <set>
- #include <ctime>
- #include <algorithm>
- #include <memory.h>
- #include <stdio.h>
- #include <stdlib.h>
- using namespace std;
- #define WR printf
- #define RE scanf
- #define PB push_back
- #define SE second
- #define FI first
- #define FOR(i,k,n) for(int i=(k); i<=(n); i++)
- #define DFOR(i,k,n) for(int i=(k); i>=(n); i--)
- #define SZ(a) (int)((a).size())
- #define FA(i,v) FOR(i,0,SZ(v)-1)
- #define RFA(i,v) DFOR(i,SZ(v)-1,0)
- #define CLR(a) memset(a, 0, sizeof(a))
- #define LL long long
- #define VI vector<int>
- #define PAR pair<int ,int>
- #define o_O 1000000000
- void __never(int a){printf("\nOPS %d", a);}
- #define ass(s) {if (!(s)) {__never(__LINE__);cout.flush();cerr.flush();abort();}}
- bool F[128];
- int ans[128][4];
- int check(int a, int b, int c, int d)
- {
- int re=0;
- while(1)
- {
- if (a+b+c+d==0) return re;
- if (re==200) return -1;
- int aa = abs(a-b), bb = abs(b-c), cc = abs(c-d), dd = abs(d-a);
- a = aa; b = bb; c = cc; d = dd;
- re++;
- }
- return -1;
- }
- void sol()
- {
- FOR(a,0,0) FOR(b,0,1000)
- {
- FOR(c,b,5000) FOR(d,c,20000)
- {
- int x = check(a,b,c,d);
- if (x>=0 && !F[x])
- {
- F[x]=true;
- //WR("%d %d %d %d %d\n", a, b, c, d, x );
- ans[x][0] = a;
- ans[x][1] = b;
- ans[x][2] = c;
- ans[x][3] = d;
- }
- }
- cerr << a << " " << b << "\n";
- }
- FOR(a,0,100) if (F[a])
- {
- FOR(b,0,3) WR("%d ", ans[a][b]);
- WR(" %d\n", a);
- }
- }
- void sol2(int i)
- {
- if (i==0) cout << "0 0 0 0\n";
- else if (i==1) cout << "1 1 1 1\n";
- else if (i==2) cout << "0 1 0 1\n";
- else if (i==3) cout << "0 0 1 1\n";
- else if (i==4) cout << "0 0 0 1\n";
- else if (i==5) cout << "0 1 2 3\n";
- else if (i==6) cout << "0 0 1 3\n";
- else if (i==7) cout << "0 1 2 4\n";
- else if (i==8) cout << "0 1 4 9\n";
- else if (i==9) cout << "0 2 5 11\n";
- else
- {
- LL A=2, B=3, C=6, D=11;
- LL z=0;
- FOR(a,10,i)
- {
- if (a%3==2)
- {
- A*=2;
- B*=2;
- C*=2;
- D*=2;
- z=(LL)((double)z*2.3829757679); // magic
- }
- else z=(LL)((double)z*1.191487883953); // another magic
- while(1)
- {
- LL aa = A+z;
- LL bb = A+aa;
- LL cc = B+bb;
- LL dd = C+cc;
- if (aa>0 && bb>=0 && cc>=0 && dd>=0 && dd-aa==D)
- {
- LL aaa = 0;
- LL bbb = aa;
- LL ccc = bbb + bb;
- LL ddd = ccc + cc;
- if (ddd == dd)
- {
- if (a==i)
- {
- //cerr << a << "\n";
- cout << aaa << " " << bbb << " " << ccc << " " << ddd << "\n";
- //cout.flush();
- return;
- }
- A = aa;
- B = bb;
- C = cc;
- D = dd;
- break;
- }
- }
- z++;
- }
- }
- }
- }
- int main()
- {
- freopen("input.txt","r",stdin);
- freopen("output.txt","w",stdout);
- int n;
- cin >> n;
- sol2(n);
- //FOR(a,0,100) sol2(a);
- //sol();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment