Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1041b02

Browse files
authored
refactor: update FastPower
1 parentfbffeb6 commit1041b02

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

‎src/main/java/com/others/FastPower.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
packagesrc.main.java.com.Others;
1+
packagesrc.main.java.com.others;
22

33
importjava.math.BigInteger;
44

@@ -7,14 +7,13 @@
77
* FastPower aims to calculate quickly in this circumstances with time complexity O(log k),
88
* where k is the index.
99
*
10-
* @author DDullahan
1110
*/
1211
publicclassFastPower {
1312
publicstaticBigIntegercalculate(BigIntegern,BigIntegerk,BigIntegermod) {
1413
BigIntegerans =BigInteger.ONE;
1514
while (!k.equals(BigInteger.ZERO)) {
1615
intodd =k.mod(BigInteger.valueOf(2)).compareTo(BigInteger.ZERO);
17-
if(odd >0){
16+
if(odd >0){
1817
ans =ans.multiply(n).mod(mod);
1918
}
2019
k =k.divide(BigInteger.valueOf(2));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp