Advertisement
Guest User

Untitled

a guest
May 29th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.51 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. /** Interface */
  6.  
  7. template <class T = int>
  8. inline T readInt();              // skip spaces, read signed int
  9. inline int readUInt();           // skip spaces, read unsigned int
  10. inline int readChar();           // skip spaces, read char
  11. inline void readWord( char *s ); // skip spaces, read word
  12.  
  13. template <class T>
  14. inline void writeInt( T x );
  15. inline void writeChar( int x ); // you may use putchar() instead of it
  16. inline void writeWord( const char *s );
  17. inline void flush();
  18.  
  19. #define ll long long
  20. #define file "real."
  21.  
  22. const int NMAX = 1e6;
  23.  
  24. struct complex1
  25. {
  26.     double r, im;
  27.  
  28.     complex1(){ }
  29.     complex1( double a, double b ) : r(a), im(b) { }
  30.  
  31.     complex1 dual () {return complex1(r, -im);}
  32.     complex1 turn () {return complex1(im, -r);}
  33.  
  34.     complex1 operator - (const complex1 &a) const {return complex1((r - a.r)/2, (im - a.im)/2);}
  35.     complex1 operator + (const complex1 &a) const {return complex1((r + a.r)/2, (im + a.im)/2);}
  36. };
  37.  
  38. complex1 a, b;
  39.  
  40. int main()
  41. {
  42.     assert ( freopen (file "in", "r", stdin) );
  43.     assert ( freopen (file "out", "w", stdout) );
  44.  
  45.     ll N = readInt();
  46.     ll A = readInt();
  47.     ll B = readInt();
  48.     ll C = readInt();
  49.     ll D = readInt();
  50.     ll E = readInt();
  51.     ll F = readInt();
  52.     ll n = readInt();
  53.     for (int i = 0; i < n; ++i)
  54.     {
  55.         ll j = readInt();
  56.         complex1 c1, c2;
  57.         ll x = (N - j) % N;
  58.         c1.r  = ((A + B*j) ^ (C*j))*(long double)(0.001);
  59.         c1.im = ((D + E*j) ^ (F*j))*(long double)(0.001);
  60.         c2.r  = ((A + B*x) ^ (C*x))*(long double)(0.001);
  61.         c2.im = ((D + E*x) ^ (F*x))*(long double)(0.001);
  62.         c2 = c2.dual();
  63.         a = c1 + c2;
  64.         b = c1 - c2;
  65.         b = b.turn();
  66.         printf("%f %f ", a.r, a.im);
  67.         printf("%f %f \n", b.r, b.im);
  68.     }
  69.     return 0;
  70. }
  71.  
  72.  
  73. /** Read */
  74.  
  75. static const int buf_size = 4096;
  76.  
  77. inline int getchar_fast() { // you may use getchar() instead of it
  78.     static char buf[buf_size];
  79.     static int len = 0, pos = 0;
  80.     if (pos == len)
  81.         pos = 0, len = fread(buf, 1, buf_size, stdin);
  82.     if (pos == len)
  83.         return -1;
  84.     return buf[pos++];
  85. }
  86.  
  87. inline int readChar() {
  88.     int c = getchar_fast();
  89.     while (c <= 32)
  90.         c = getchar_fast();
  91.     return c;
  92. }
  93.  
  94. inline int readUInt() {
  95.     int c = readChar(), x = 0;
  96.     while ('0' <= c && c <= '9')
  97.         x = x * 10 + c - '0', c = getchar_fast();
  98.     return x;
  99. }
  100.  
  101. template <class T>
  102. inline T readInt() {
  103.     int s = 1, c = readChar();
  104.     T x = 0;
  105.     if (c == '-')
  106.         s = -1, c = getchar_fast();
  107.     while ('0' <= c && c <= '9')
  108.         x = x * 10 + c - '0', c = getchar_fast();
  109.     return s == 1 ? x : -x;
  110. }
  111.  
  112. inline void readWord( char *s ) {
  113.     int c = readChar();
  114.     while (c > 32)
  115.         *s++ = c, c = getchar_fast();
  116.     *s = 0;
  117. }
  118.  
  119. /** Write */
  120.  
  121. static int write_pos = 0;
  122. static char write_buf[buf_size];
  123.  
  124. inline void writeChar( int x ) {
  125.   if (write_pos == buf_size)
  126.     fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
  127.   write_buf[write_pos++] = x;
  128. }
  129.  
  130. inline void flush() {
  131.   if (write_pos)
  132.     fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
  133. }
  134.  
  135. template <class T>
  136. inline void writeInt( T x ) {
  137.   if (x < 0)
  138.     writeChar('-'), x = -x;
  139.  
  140.   char s[24];
  141.   int n = 0;
  142.   while (x || !n)
  143.     s[n++] = '0' + x % 10, x /= 10;
  144.   while (n--)
  145.     writeChar(s[n]);
  146. }
  147.  
  148. inline void writeWord( const char *s ) {
  149.   while (*s)
  150.     writeChar(*s++);
  151. }
  152. /** End of magic */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement