题解 | #Where in 和Not in#

末尾0的个数

http://www.nowcoder.com/practice/6ffdd7e4197c403e88c6a8aa3e7a332a

import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class Main{ public static void main(String[] args)throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String str = null; while((str = in.readLine()) != null){ String[] s = str.split(" "); int n = Integer.parseInt(s[0]); int sum = 0; for(int i = 1;i<=n;i++){ int temp = i; while(temp % 5 == 0){ sum ++; temp /= 5; if(temp == 0) break; } } System.out.println(sum);

    }
}

}

全部评论

相关推荐

2025-12-18 11:59
广州南方学院 C++
牛客78682892...:直接点还好,总比要了简历也不回的强
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务