标签:des style blog color io os for div sp
很巧妙的思路:先计算A之前的被K除的最大数,然后计算B-A之间能填充多少个K
1 // you can use includes, for example: 2 // #include <algorithm> 3 4 // you can write to stdout for debugging purposes, e.g. 5 // cout << "this is a debug message" << endl; 6 7 int solution(int A, int B, int K) { 8 // write your code in C++11 9 if(A % K ==0) 10 { 11 return (B-A)/K+1;//加上A 12 } 13 else 14 { 15 return (B-(A-A%K))/K; 16 } 17 }
标签:des style blog color io os for div sp
原文地址:http://www.cnblogs.com/cane/p/3973879.html