fork download
  1.  
  2. using namespace std;
  3.  
  4. typedef vector<vector<long long>> matrix;
  5.  
  6. const long long mod = 1000000007LL;
  7.  
  8. matrix operator * (const matrix &a, const matrix &b) {
  9.  
  10. int n = a.size();
  11.  
  12. matrix c(n, vector<long long>(n));
  13.  
  14. for (int i = 0; i < n; i++) {
  15.  
  16. for (int j = 0; j < n; j++) {
  17.  
  18. for (int k = 0; k < n; k++) {
  19.  
  20. c[i][j] += a[i][k] * b[k][j];
  21.  
  22. }
  23.  
  24. c[i][j] %= mod;
  25.  
  26. }
  27.  
  28. }
  29.  
  30. return c;
  31.  
  32. }
  33.  
  34.  
  35.  
  36.  
  37.  
  38. int main(void)
  39.  
  40. {
  41.  
  42. long long n;
  43.  
  44. cin >> n;
  45.  
  46. if (n <= 1) {
  47.  
  48. cout << n << '\n';
  49.  
  50. return 0;
  51.  
  52. }
  53.  
  54. matrix ans = { { 1, 0 },{ 0, 1 } };
  55.  
  56. matrix a = { { 1, 1 },{ 1, 0 } };
  57.  
  58.  
  59.  
  60. while (n > 0) {
  61.  
  62. if (n % 2 == 1) {
  63.  
  64. ans = ans * a;
  65.  
  66. }
  67.  
  68. a = a * a;
  69.  
  70. n /= 2;
  71.  
  72. }
  73.  
  74.  
  75.  
  76. cout << ans[0][1] << '\n';
  77.  
  78.  
  79.  
  80. return 0;
  81.  
  82. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:2:1: error: unknown type name ‘using’
 using namespace std;
 ^~~~~
prog.c:2:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘std’
 using namespace std;
                 ^~~
prog.c:4:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
 typedef vector<vector<long long>> matrix;
               ^
prog.c:8:1: error: unknown type name ‘matrix’
 matrix operator * (const matrix &a, const matrix &b) {
 ^~~~~~
prog.c:8:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
 matrix operator * (const matrix &a, const matrix &b) {
                 ^
prog.c: In function ‘main’:
prog.c:44:2: error: ‘cin’ undeclared (first use in this function)
  cin >> n;
  ^~~
prog.c:44:2: note: each undeclared identifier is reported only once for each function it appears in
prog.c:48:3: error: ‘cout’ undeclared (first use in this function)
   cout << n << '\n';
   ^~~~
prog.c:54:2: error: unknown type name ‘matrix’
  matrix ans = { { 1, 0 },{ 0, 1 } };
  ^~~~~~
prog.c:54:2: warning: braces around scalar initializer
prog.c:54:2: note: (near initialization for ‘ans’)
prog.c:54:22: warning: excess elements in scalar initializer
  matrix ans = { { 1, 0 },{ 0, 1 } };
                      ^
prog.c:54:22: note: (near initialization for ‘ans’)
prog.c:54:2: warning: braces around scalar initializer
  matrix ans = { { 1, 0 },{ 0, 1 } };
  ^~~~~~
prog.c:54:2: note: (near initialization for ‘ans’)
prog.c:54:31: warning: excess elements in scalar initializer
  matrix ans = { { 1, 0 },{ 0, 1 } };
                               ^
prog.c:54:31: note: (near initialization for ‘ans’)
prog.c:54:26: warning: excess elements in scalar initializer
  matrix ans = { { 1, 0 },{ 0, 1 } };
                          ^
prog.c:54:26: note: (near initialization for ‘ans’)
prog.c:56:2: error: unknown type name ‘matrix’
  matrix a = { { 1, 1 },{ 1, 0 } };
  ^~~~~~
prog.c:56:2: warning: braces around scalar initializer
prog.c:56:2: note: (near initialization for ‘a’)
prog.c:56:20: warning: excess elements in scalar initializer
  matrix a = { { 1, 1 },{ 1, 0 } };
                    ^
prog.c:56:20: note: (near initialization for ‘a’)
prog.c:56:2: warning: braces around scalar initializer
  matrix a = { { 1, 1 },{ 1, 0 } };
  ^~~~~~
prog.c:56:2: note: (near initialization for ‘a’)
prog.c:56:29: warning: excess elements in scalar initializer
  matrix a = { { 1, 1 },{ 1, 0 } };
                             ^
prog.c:56:29: note: (near initialization for ‘a’)
prog.c:56:24: warning: excess elements in scalar initializer
  matrix a = { { 1, 1 },{ 1, 0 } };
                        ^
prog.c:56:24: note: (near initialization for ‘a’)
prog.c:76:13: error: subscripted value is neither array nor pointer nor vector
  cout << ans[0][1] << '\n';
             ^
stdout
Standard output is empty