Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //SkyHawk, CMC MSU
- #include <stdio.h>
- #include <iostream>
- #include <list>
- #include <string>
- #include <vector>
- #include <iterator>
- #include <algorithm>
- #include <cmath>
- #include <cstring>
- #include <set>
- #include <list>
- #include <queue>
- using namespace std;
- #define FOR(i,n) for(int i = 0;i < n;++i)
- #define PII pair<int,int>
- #define MIN(a,b) ((a)>(b)?(b):(a))
- #define MAX(a,b) ((a)>(b)?(a):(b))
- int precalc[8][4] = {{0, 0, 0, 0},
- {1, 1, 1, 1},
- {0, 1, 0, 1},
- {0, 0, 1, 1},
- {0, 0, 0, 1},
- {0, 1, 2, 3},
- {0, 0, 1, 3},
- {0, 1, 2, 4}};
- long long ar[4];
- int main(int argc, char** argv)
- {
- freopen("input.txt","r",stdin);
- freopen("output.txt","w",stdout);
- int n;
- cin >> n;
- if(n<=7)
- {
- FOR(i,4)
- cout << precalc[n][i] << " ";
- cout << endl;
- return 0;
- }
- FOR(i,4)
- ar[i] = precalc[7][i];
- for(int i = 8;i<=n;++i)
- {
- long long x = abs(ar[3]-ar[1]-ar[2]);
- if(x%2)
- {
- FOR(j,4)
- ar[j] = ar[j]*2;
- x*=2;
- }
- x /=2;
- long long t2 = x + ar[1] +x;
- long long t3 = t2 + ar[2] + x;
- ar[0] = 0;
- ar[1] = x;
- ar[2] = t2;
- ar[3] = t3;
- }
- FOR(i,4)
- cout << ar[i] << " ";
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment