hdu 1061 Rightmost Digit(快速冪取餘)

一般的求冪再對10取餘會超時,用快速冪 #include <iostream> #include <cstdio> using namespace std; int mod_exp(int a, int b, int c) //快速冪取餘a^b%c { int res, t; res = 1 % c; t = a % c; while (b)
相關文章
相關標籤/搜索