蓝桥杯-本质上升序列
1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 string A="tocyjkdzcieoiodfpbgcncsrjbhmugdnojjddhllnofawllbhfiadgdcdjstemphmnjihecoapdjjrprrqnhgccevdarufmliqijgihhfgdcmxvicfauachlifhafpdccfseflcdgjncadfclvfmadvrnaaahahndsikzssoywakgnfjjaihtniptwoulxbaeqkqhfwl"; 6 long long int aa[100000]={0}; 7 8 for(int i=0;i<A.length();i++) 9 { 10 aa[i]=1; 11 } 12 13 for(int i=0;i<A.length();i++) 14 { 15 for(int j=0;j<i;j++) 16 { 17 if(A[i]>A[j])aa[i]+=aa[j]; 18 if(A[j]==A[i])aa[i]-=aa[j]; 19 } 20 } 21 int sum=0; 22 for(int i=0;i<A.length();i++) 23 { 24 sum += aa[i]; 25 } 26 cout << sum << endl; 27 return 0; 28 }