[关闭]
@chawuciren 2019-09-21T16:02:14.000000Z 字数 190 阅读 431

CINTA作业7-编程题【模指数】

CINTA


  1. /*
  2. * Input: three integers:x,y and m
  3. * Output: (x^y)%m
  4. * Method: iterative method
  5. */
  6. int ModulusIndex(int x,int y,int m){
  7. int res=1;
  8. while(y){
  9. if(y&1){
  10. res=res*x%m;
  11. }
  12. x=x*x%m;
  13. y=y>>1;
  14. }
  15. return res;
  16. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注