java写的,只有30分,四个超时,三个错误,求dl指点
查看原帖
java写的,只有30分,四个超时,三个错误,求dl指点
1444408
AnPotato楼主2024/9/18 17:36
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //摇骰子的次数
        int n = sc.nextInt();
        //我们期望的数
        long k = 1000000007;
        int count = 0;
        //找到n次投掷后的最大数
        long max = 0;
        for(int i = n;i >= 1;i--){
            max += 6*Math.pow(10,i-1);
        }
        while(max >= k){
            if(max%k==0){
                count++;
                max--;
            }
            max--;
        }
        System.out.println(count);
    }
}
2024/9/18 17:36
加载中...