Advertisement
Guest User

2015 Challenge24 Finals: C3 (original) by HoChockiGon

a guest
Jul 2nd, 2015
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.40 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <sys/time.h>
  3.  
  4. using namespace std;
  5.  
  6. #define FI first
  7. #define SE second
  8. #define X first
  9. #define Y second
  10. #define ST first
  11. #define ND second
  12. #define MP make_pair
  13. #define PB push_back
  14.  
  15. typedef long long LL;
  16. typedef vector<int> VI;
  17. typedef long double LD;
  18. typedef pair<int,int> PII;
  19.  
  20. #define REP(i,n) for(int i=0;i<(n);++i)
  21. #define FOR(i,a,b) for(int i=(a);i<(b);++i)
  22. #define FORE(a,b) for(VAR(a,(b).begin());a!=(b).end();++a)
  23. #define VAR(a,b) __typeof(b) a=(b)
  24. #define ALL(x) (x).begin(),(x).end()
  25. #define CLR(x,a) memset(x,a,sizeof(x))
  26.  
  27. double getTime() {
  28.     timeval tv;
  29.     gettimeofday(&tv, NULL);
  30.     return tv.tv_sec + tv.tv_usec * 1e-6;
  31. }
  32.  
  33. int d1000(int x) {
  34.     if (x < 0) {
  35.         return -((-x + 999) / 1000);
  36.     } else {
  37.         return x / 1000;
  38.     }
  39. }
  40.  
  41. bool should_color(int x, int y) {
  42.     LL a = x;
  43.     LL b = y;
  44.     REP (i, 30) {
  45.         LL a2 = d1000(a * a - b * b);
  46.         LL b2 = d1000(2 * a * b);
  47.         if (a2 > 4000) {
  48.             return false;
  49.         }
  50.         a = a2 + x;
  51.         b = b2 + y;
  52.     }
  53.     return true;
  54. }
  55.  
  56. int main() {
  57.     int x0, y0, x1, y1;
  58.     cin >> x0 >> y0 >> x1 >> y1;
  59.     FOR (x, x0, x1) {
  60.         FOR (y, y0, y1) {
  61.             if (should_color(x * 5, y * 5)) {
  62.                 cout << "X";
  63.             } else {
  64.                 cout << ".";
  65.             }
  66.         }
  67.         cout << endl;
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement