1 /// <summary> 2 /// Solution 3 /// 通过率 100% 4 /// </summary> 5 /// <param name="A"></param> 6 /// <param name="B"></param> 7 /// <param name="K"></param> 8 /// <returns></returns> 9 public int solution(int A, int B, int K) 10 { 11 if (A % K == 0 || B % K == 0) 12 { 13 return (B - A) / K + 1; 14 } 15 else 16 { 17 if (A > K) 18 { 19 return (B - A) / K; 20 } 21 else 22 { 23 return B / K; 24 } 25 } 26 }
时间: 2024-10-12 05:09:45