fork download
  1. program rsa;
  2. const MaxL=100;
  3. var N, d, L ,pot, b,e,m, i:int64;
  4. messaggio : array [0..maxL] of int64;
  5. plaintext : array [0..maxL] of char;
  6.  
  7. function fast_pow (base:int64; esp:int64; modd:int64) :int64;
  8. var meta :int64;
  9. begin
  10. if esp = 0 then fast_pow:=1
  11. else
  12. if esp = 1 then fast_pow:= base mod modd
  13. else
  14. begin
  15. meta := fast_pow(base, esp div 2, modd);
  16. if esp mod 2 =0 then fast_pow:= (meta*meta) mod modd
  17. else fast_pow:= (meta*meta * base) mod modd;
  18. end;
  19. end;
  20. begin
  21. readln(b,e,m);
  22. pot:=fast_pow(b,e,m);
  23. writeln(pot);
  24. end.
Success #stdin #stdout 0s 5304KB
stdin
119 3 145 
stdout
114