leetcode 剑指 Offer 14- II. 剪绳子 II
2021-01-31 本文已影响0人
flood_d
0.code
class Solution {
public int cuttingRope(int n) {
if(n==2){
return 1;
}
if(n==3){
return 2;
}
int mod = 1000000007;
long res = 1;
while(n>4){
res = res*3;
res = res%mod;
n = n -3;
}
return (int)(res*n%mod);
}
}