小红书4.23

01

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    static long[] cc= new long[100005];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Long> a = new ArrayList<>();
        long max =0;
        for(int i=0;i < n;i++){
            long temp = sc.nextLong();
            a.add(temp);
            if(i == 0){
                max = temp;
            }
            if(max < temp){
                max = temp;
            }
        }
        res(max);
        long result = 0 ;
        for(int i=0;i < n;i++){
            result = (result + cc[a.get(i).intValue()])% 1000000007; // 强制类型转换
        }
        System.out.println(result);

    }
    private static long res(long a){
        if(a == 0){
            cc[0] = 1;
            return 1;
        }else{
            Long temp = (1+(a+1) * res(a-1))% 1000000007;
            cc[(int)a] = temp.intValue(); // 强制类型转换
            return temp;
        }
    }
}

全部评论
过了吗
点赞 回复
分享
发布于 2023-04-24 19:00 四川
笔试a多少
点赞 回复
分享
发布于 2023-04-24 19:15 湖南
滴滴
校招火热招聘中
官网直投

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务