fork(7) download
  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. using namespace std;
  7. const int M = 1e9 + 7;
  8.  
  9. __int128 powmod(__int128 e, __int128 p) {
  10. if (p == 0) {
  11. return 1;
  12. }
  13. __int128 a = 1;
  14. while (p > 1) {
  15. if (p % 2 == 0) {
  16. e = (e * e) % M;
  17. p /= 2;
  18. } else {
  19. a = (a * e) % M;
  20. e = (e * e) % M;
  21. p = (p - 1) / 2;
  22. }
  23. }
  24. return (a * e) % M;
  25. }
  26.  
  27. int main() {
  28. int n, k;
  29. cin >> n >> k;
  30.  
  31. __int128 x = 0;
  32. for (int i = 1; i <= n; i++) {
  33. __int128 t = powmod(k, __gcd(i, n));
  34. x += t % M;
  35. }
  36. cout << (int)(((double)1 / n) * x) % M;
  37. return 0;
  38. }
  39.  
  40.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
5 2
compilation info
prog.cpp:9:5: error: expected unqualified-id before '__int128'
     __int128 powmod(__int128 e, __int128 p) {
     ^
stdout
Standard output is empty