第一题经典题目 第二题可以二分解决,代码见下面 import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); sc.useDelimiter("[ \n]"); int times = sc.nextInt(); System.out.println(calc(1, times)); } private static long calc(long begin, long end) { long ans = 1; if (begin - end > 10) { return calc(begin, end / 2) * calc(end / 2 + 1, end); } for (long i = begin; i <= end; i++) { long temp = i; while (temp % 10 == 0) { temp /= 10; } ans *= temp; ans %= 1_000_000_000; while (ans % 10 == 0) { ans /= 10; } } return ans % 10; } } 第三题分情况然后动态规划
点赞 评论

相关推荐

点赞 评论 收藏
转发
牛客网
牛客企业服务