PAT 1040 C 完美运行 答案正确 #include<iostream> #include<algorithm> int main() { std::string S; std::cin>>S; long long int P{},A{},T{},D=1000000007; for_each(S.begin(),S.end(),[&,D](char C){if(C=='P')P ;if(C=='A')A=(A P)%D;if(C=='T')T=(A T)%D;}); std::cout<<T; }