其他分享
首页 > 其他分享> > pat乙级 有几个pat(类似于跳楼梯问题)

pat乙级 有几个pat(类似于跳楼梯问题)

作者:互联网

PAT真题在线练习_过20题领考试代金券_牛客题霸_牛客网

import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] arr =str.toCharArray();
        int p = 0;
        int pa = 0;
        int pat = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == 'P'){
                p++;
            }else if (arr[i] == 'A'){
                pa += p;
                pa %= 1000000007;
            }else{
                pat += pa;
                pat %= 1000000007;
            }
        }
        System.out.println(pat);
    }
}

标签:arr,pat,int,System,乙级,pa,1000000007,楼梯
来源: https://blog.csdn.net/zhijianggamer/article/details/121285252