标签:blog class code java tar int
最近在学scala语言,scala代码如下:
import scala.collection.JavaConversions._ object Solution { def solution(A: Int, B: Int, K: Int): Int = { // write your code in Scala 2.10 var cnt: Int = 0 // let start element to be zero if(A%K != 0) cnt -= K-A%K // let end element to be zero too if(B%K != 0) cnt -= B%K cnt += B-A+1 if(cnt <= 0) 0 else cnt/K+cnt%K } }
[codility]CountDiv,布布扣,bubuko.com
标签:blog class code java tar int
原文地址:http://blog.csdn.net/sunbaigui/article/details/24933663