Open thafnhlong opened 2 years ago
X >= 1 <=1e9 A >= 1 <=1e9
A = 1 B < 0 => 1 B = 0 => 1 B > 0 => 1 A > 1 B < 0 => 0 B = 0 => 1 B > 0 => round(A^B/X)*X
Rút gọn 1:
Rút gọn 2:
int closestNumber(int a, int b, int x) { if(a==1 || b==0){ if (x==1) return 1; return 0; } if (b<0) return 0; return (long)(round(pow(a,b)/x))*x; }
Constraint:
X >= 1 <=1e9 A >= 1 <=1e9
A = 1 B < 0 => 1 B = 0 => 1 B > 0 => 1 A > 1 B < 0 => 0 B = 0 => 1 B > 0 => round(A^B/X)*X
Rút gọn 1:
Rút gọn 2:
Code