Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. #include<conio.h>
  2. #include<math.h>
  3. #include<vector>
  4. #include<string>
  5. #include<fstream>
  6. #include<iostream>
  7. #include<istream>
  8. #include <limits>
  9. #include<algorithm>
  10. #include<cctype>
  11. #include<deque>
  12. #include<iterator>
  13. #include <bitset>
  14. using namespace std;
  15.  
  16.  
  17. int main() {
  18.  
  19. std::ios::sync_with_stdio(false);
  20. cin.tie(0);
  21.  
  22. //freopen("num2perm.in", "r", stdin);
  23. //freopen("num2perm.out", "w", stdout);
  24.  
  25. int n;
  26.  
  27. cin >> n;
  28. unsigned long long **mas;
  29. mas = new unsigned long long *[10];
  30. for (int i = 0; i < 10; i++) {
  31.  
  32. mas[i] = new unsigned long long int[n];
  33. }
  34. for (int i = 0; i < 10; i++) {
  35. for (int j = 0; j < n; j++) {
  36. mas[i][j] = 0;
  37. }
  38. }
  39. for (int i = 0; i < 10; i++) {
  40. if (i == 0 || i == 8) {
  41. mas[i][0] = 0;
  42. }
  43. else {
  44. mas[i][0] = 1;
  45. }
  46. }
  47.  
  48. /* for (int i = 0; i < 10; i++) {
  49. for (int j = 0; j < n; j++) {
  50. cout << mas[i][j] << " ";
  51. }
  52. cout << endl;
  53. }*/
  54. //mas[12][n];
  55. // mas[i][n-1]
  56. //mas[4][k]= mas[0][k-1]+mas[3][k-1] +mas[9][k-1];
  57. unsigned long long count = 0;
  58. for (int i = 1; i < n; i++) {
  59. mas[0][i] = (mas[4][i-1 ] + mas[6][i-1])% 1000000000;
  60. mas[1][i] = (mas[6][i - 1] + mas[8][i - 1])%1000000000;
  61. mas[2][i] = (mas[7][i - 1] + mas[9][i - 1]) % 1000000000;
  62. mas[3][i] = (mas[4][i - 1] + mas[8][i - 1]) % 1000000000;
  63. mas[4][i] = (mas[0][i - 1] + mas[3][i - 1]+mas[9][i-1]) % 1000000000;
  64. mas[6][i] = (mas[0][i - 1] + mas[1][i - 1]+mas[7][i-1]) % 1000000000;
  65. mas[7][i] = (mas[2][i - 1] + mas[6][i - 1]) % 1000000000;
  66. mas[8][i] = (mas[1][i - 1] + mas[3][i - 1]) % 1000000000;
  67. mas[9][i] = (mas[2][i - 1] + mas[4][i - 1]) % 1000000000;
  68.  
  69. }
  70.  
  71.  
  72. for (int i = 0; i < 10; i++) {
  73.  
  74. count = (count + mas[i][n - 1])% 1000000000;
  75.  
  76. }
  77.  
  78. count = count % 1000000000;
  79. cout << count;
  80.  
  81. return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement