fork download
  1. std::tuple<int, int, int> egcd(int a, int b){
  2. if(a == 0) return {b, 0, 1};
  3. int x, y, gcd;
  4. std::tie(gcd, x, y) = egcd(b%a, a);
  5. return {gcd, y - (b / a) * x, x};
  6. }
  7. int modinv(int a, int m){
  8. int gcd, x, y;
  9. std::tie(gcd, x, y) = egcd(a, m);
  10. return (x%m + m) % m;
  11. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:6: error: ‘tuple’ in namespace ‘std’ does not name a template type
 std::tuple<int, int, int> egcd(int a, int b){
      ^~~~~
prog.cpp:1:1: note: ‘std::tuple’ is defined in header ‘<tuple>’; did you forget to ‘#include <tuple>’?
+#include <tuple>
 std::tuple<int, int, int> egcd(int a, int b){
 ^~~
prog.cpp: In function ‘int modinv(int, int)’:
prog.cpp:9:6: error: ‘tie’ is not a member of ‘std’
 std::tie(gcd, x, y) = egcd(a, m);
      ^~~
prog.cpp:9:23: error: ‘egcd’ was not declared in this scope
 std::tie(gcd, x, y) = egcd(a, m);
                       ^~~~
prog.cpp:9:23: note: suggested alternative: ‘gcd’
 std::tie(gcd, x, y) = egcd(a, m);
                       ^~~~
                       gcd
stdout
Standard output is empty