Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #pragma comment(linker, "/stack:16777216")
  3. #include <string>
  4. #include <vector>
  5. #include <map>
  6. #include <list>
  7. #include <iterator>
  8. #include <set>
  9. #include <queue>
  10. #include <iostream>
  11. #include <sstream>
  12. #include <stack>
  13. #include <deque>
  14. #include <cmath>
  15. #include <memory.h>
  16. #include <cstdlib>
  17. #include <cstdio>
  18. #include <cctype>
  19. #include <algorithm>
  20. #include <utility>
  21. using namespace std;
  22.  
  23. #define FOR(i, a, b) for(int i = (a); i < (b); ++i)
  24. #define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
  25. #define REP(i, N) FOR(i, 0, N)
  26. #define RREP(i, N) RFOR(i, N, 0)
  27. #define FILL(A,value) memset(A,value,sizeof(A))
  28.  
  29. #define ALL(V) V.begin(), V.end()
  30. #define SZ(V) (int)V.size()
  31. #define PB push_back
  32. #define MP make_pair
  33. #define Pi 3.14159265358979
  34.  
  35. typedef long long Int;
  36. typedef unsigned long long UINT;
  37. typedef vector <int> VI;
  38. typedef pair <int, int> PII;
  39.  
  40. const int INF = 1000000000;
  41. const int MAX = 74;
  42. const int MAX2 = 7000;
  43. const int BASE = 1000000000;
  44.  
  45. struct Matrix
  46. {
  47. unsigned a[2][2];
  48. Matrix()
  49. {
  50. a[0][0] = a[1][1] = 1;
  51. a[0][1] = a[1][0] = 0;
  52. }
  53.  
  54. void operator*=(Matrix b)
  55. {
  56. unsigned c[2][2];
  57. FILL(c,0);
  58.  
  59. FOR(i,0,2)
  60. {
  61. FOR(j,0,2)
  62. {
  63. FOR(k,0,2)
  64. {
  65. c[i][j] += a[i][k] * b[k][j];
  66. }
  67. }
  68. }
  69.  
  70. FOR(i,0,2)
  71. {
  72. FOR(j,0,2)
  73. {
  74. a[i][j] = c[i][j];
  75. }
  76. }
  77. }
  78. };
  79.  
  80. Matrix bpow(Matrix a, Int k)
  81. {
  82. Matrix res;
  83. while (k)
  84. {
  85. if (k & 1)
  86. {
  87. res *= a;
  88. }
  89. a *= a;
  90. k /= 2;
  91. }
  92. return res;
  93. }
  94.  
  95. int n,m,s,d;
  96.  
  97. int val(int x, int y)
  98. {
  99. Matrix a;
  100. a.a[0][0] = 1664525;
  101. a.a[0][1] = 1013904223;
  102. a = bpow(a , 1LL * x * m + y);
  103. return (a.a[0][0] * s + a.a[0][1]) % 3;
  104. }
  105.  
  106. int main()
  107. {
  108. #ifndef ONLINE_JUDGE
  109. // freopen("in.txt", "r", stdin);
  110. #endif
  111.  
  112. //freopen("domino-tiling.in" , "r" , stdin);
  113. //freopen("domino-tiling.out" , "w" , stdout);
  114.  
  115. cin >> n >> m >> d >> s;
  116.  
  117.  
  118.  
  119. return 0;
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement