摘要: 求 \(a^b\),先上代码吧 int qsm(int a,int b){ int ans = 1,base = a; while(b){ if(b&1) ans *= base; base *= base; b>>=1; } return ans; } 以 \(a = 3, b = 21\) 为例 阅读全文
posted @ 2021-10-04 16:00 xqy2003 阅读(43) 评论(0) 推荐(0)
摘要: 先上代码吧 int num; while(n){ num = n%k; n /= k; } //其中n为十进制数,要转k进制,num为每个位上的数. 举个例子: \(121\) , 转 \(5\) 进制,\(121 =\) \(4 \times 5^2\) + \(4 \times 5^1\) + 阅读全文
posted @ 2021-10-04 15:06 xqy2003 阅读(383) 评论(0) 推荐(1)