fork(1) download
  1. #include <gmp.h>
  2. #include <iostream>
  3. extern "C" {
  4. void *__libc_dlopen_mode(const char *x, int y);
  5. void *__libc_dlsym(void *x, const char *y);
  6. }
  7.  
  8. const char *gmp_path = "/usr/lib/x86_64-linux-gnu/libgmp.so.10";
  9. void *gmp_lib = __libc_dlopen_mode(gmp_path, 2);
  10. void *get(const char *name) { return __libc_dlsym(gmp_lib, name); }
  11.  
  12. #define D(name) const auto __##name = (decltype(name) *)get("__g" #name)
  13. D(mpn_mul);
  14. D(mpn_tdiv_qr);
  15. D(mpn_set_str);
  16. D(mpn_get_str);
  17. D(mpn_sub_n);
  18.  
  19. D(mpz_init);
  20. D(mpz_clear);
  21. D(mpz_invert);
  22. D(mpz_import);
  23. D(mpz_out_str);
  24. #undef D
  25.  
  26. int main() {
  27. mpz_t a;
  28. mp_limb_t v1[100], v2[100];
  29. for (int i = 0; i < 100; i++) {
  30. v1[i] = 4 * i;
  31. v2[i] = 5 * i;
  32. }
  33. std::cout << __mpn_sub_n(v1, v1, v2, 10) << "\n";
  34. for (int i = 0; i < 100; i++) {
  35. std::cout << v1[i] << " ";
  36. }
  37. __mpz_init(a);
  38. __mpz_clear(a);
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0.01s 5284KB
stdin
1
2
10
42
11
stdout
1
0 18446744073709551615 18446744073709551613 18446744073709551612 18446744073709551611 18446744073709551610 18446744073709551609 18446744073709551608 18446744073709551607 18446744073709551606 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120 124 128 132 136 140 144 148 152 156 160 164 168 172 176 180 184 188 192 196 200 204 208 212 216 220 224 228 232 236 240 244 248 252 256 260 264 268 272 276 280 284 288 292 296 300 304 308 312 316 320 324 328 332 336 340 344 348 352 356 360 364 368 372 376 380 384 388 392 396