dp

解码方法

http://www.nowcoder.com/questionTerminal/b83b126603dd4e63bc4287d32d754886

import java.util.Arrays;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        char[] ch = sc.nextLine().toCharArray();

        int[]dp = new int[ch.length];
        dp[0] = 1;
        dp[1] = 2;
        for(int i=2;i<ch.length;++i) {
            dp[i] += dp[i-1];
            //看看前面那个能否 <=26
            if(ch[i-1]<='2'&& ch[i]<='6') {
                dp[i]+=dp[i-2];
            }
        }
        System.out.println(dp[ch.length-1]);


    }

    public static int max(int... a) {
        return Arrays.stream(a).max().getAsInt();
    }



}
全部评论
如果28呢
点赞 回复 分享
发布于 2020-05-31 21:35

相关推荐

03-04 19:02
云南大学 Java
Yki_:没挂,只是没人捞,该干啥干啥,等着就好了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务