/* Copyright 2016 AcrossTheSky */ #include <iostream> #include <cstdio> #include <utility> #include <cassert> #include <map> #include <vector> #include <deque> #include <queue> #include <stack> #include <set> #include <cstring> #include <cstdlib> #include <cctype> #include <sstream> #include <fstream> #include <string> #include <cmath> #include <algorithm> #define REP(i, a, b) for (int i = (a); i <= (b); ++i) #define PER(i, a, b) for (int i = (a); i >= (b); --i) #define RVC(i, c) fot (int i = 0; i < (c).size(); ++i) #define RED(k, u) for (int k = head[(u)]; k; k = edge[k].next) #define lowbit(x) ((x) & (-(x))) #define CL(x, v) memset(x, v, sizeof x) #define MP std::make_pair #define PB push_back #define FR first #define SC second #define rank rankk #define next nextt #define link linkk #define index indexx #define abs(x) ((x) > 0 ? (x) : (-(x))) using namespace std; typedef long long LL; typedef pair<int, int> PII; template<class T> inline bool getmin(T *a, const T &b) { if (b < *a) { *a = b; return true; } return false; } template<class T> inline bool getmax(T *a, const T &b) { if (b > *a) { *a = b; return true; } return false; } template<class T> inline void read(T *a) { char c; while (isspace(c = getchar())) {} bool flag = 0; if (c == '-') flag = 1, *a = 0; else *a = c - 48; while (isdigit(c = getchar())) *a = *a * 10 + c - 48; if (flag) *a = -*a; } const int mo = 1000000007; template<class T> T pow(T a, T b, int c = mo) { T res = 1; for (T i = 1; i <= b; i <<= 1, a = 1LL * a * a % c) if (b & i) res = 1LL * res * a % c; return res; } /*======================= TEMPLATE =======================*/ #include "cielib.h" const int N = 510; int s[N], t[N]; int a[N], b[N], c[N]; bool check() { czyCieplo(a); return czyCieplo(b); } int main() { int d = podajD(); int r = podajR(); REP(i, 0, d - 1) s[i] = 0, t[i] = r; bool flag = 0; while (1) { REP(i, 0, d - 1) b[i] = a[i] = c[i] =(s[i] + t[i]) / 2; REP(i, 0, d - 1) if (t[i] - s[i] == 2) { flag = 1; bool c1 = 0, c2 = 0; a[i] = t[i], b[i] = s[i]; c1 = check(); a[i] = s[i], b[i] = t[i]; c2 = check(); if (!c1 && !c2) s[i] = c[i]; else if (c2) s[i] = t[i]; a[i] = b[i] = c[i]; } else { a[i] = t[i], b[i] = s[i]; if (check()) t[i] = s[i] + (t[i] - s[i] + 1) / 2; else s[i] = t[i] - (t[i] - s[i] + 1) / 2; a[i] = b[i] = c[i]; } if (flag) break; } znalazlem(s); return 0; }
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | /* Copyright 2016 AcrossTheSky */ #include <iostream> #include <cstdio> #include <utility> #include <cassert> #include <map> #include <vector> #include <deque> #include <queue> #include <stack> #include <set> #include <cstring> #include <cstdlib> #include <cctype> #include <sstream> #include <fstream> #include <string> #include <cmath> #include <algorithm> #define REP(i, a, b) for (int i = (a); i <= (b); ++i) #define PER(i, a, b) for (int i = (a); i >= (b); --i) #define RVC(i, c) fot (int i = 0; i < (c).size(); ++i) #define RED(k, u) for (int k = head[(u)]; k; k = edge[k].next) #define lowbit(x) ((x) & (-(x))) #define CL(x, v) memset(x, v, sizeof x) #define MP std::make_pair #define PB push_back #define FR first #define SC second #define rank rankk #define next nextt #define link linkk #define index indexx #define abs(x) ((x) > 0 ? (x) : (-(x))) using namespace std; typedef long long LL; typedef pair<int, int> PII; template<class T> inline bool getmin(T *a, const T &b) { if (b < *a) { *a = b; return true; } return false; } template<class T> inline bool getmax(T *a, const T &b) { if (b > *a) { *a = b; return true; } return false; } template<class T> inline void read(T *a) { char c; while (isspace(c = getchar())) {} bool flag = 0; if (c == '-') flag = 1, *a = 0; else *a = c - 48; while (isdigit(c = getchar())) *a = *a * 10 + c - 48; if (flag) *a = -*a; } const int mo = 1000000007; template<class T> T pow(T a, T b, int c = mo) { T res = 1; for (T i = 1; i <= b; i <<= 1, a = 1LL * a * a % c) if (b & i) res = 1LL * res * a % c; return res; } /*======================= TEMPLATE =======================*/ #include "cielib.h" const int N = 510; int s[N], t[N]; int a[N], b[N], c[N]; bool check() { czyCieplo(a); return czyCieplo(b); } int main() { int d = podajD(); int r = podajR(); REP(i, 0, d - 1) s[i] = 0, t[i] = r; bool flag = 0; while (1) { REP(i, 0, d - 1) b[i] = a[i] = c[i] =(s[i] + t[i]) / 2; REP(i, 0, d - 1) if (t[i] - s[i] == 2) { flag = 1; bool c1 = 0, c2 = 0; a[i] = t[i], b[i] = s[i]; c1 = check(); a[i] = s[i], b[i] = t[i]; c2 = check(); if (!c1 && !c2) s[i] = c[i]; else if (c2) s[i] = t[i]; a[i] = b[i] = c[i]; } else { a[i] = t[i], b[i] = s[i]; if (check()) t[i] = s[i] + (t[i] - s[i] + 1) / 2; else s[i] = t[i] - (t[i] - s[i] + 1) / 2; a[i] = b[i] = c[i]; } if (flag) break; } znalazlem(s); return 0; } |