24分求助!!!

P3741 小果的键盘

```cpp #include<iostream> using namespace std;int n,ans,tmp;char a[110],b[110];int main(){cin>>n;for(int i=0;i<n;i++)cin>>a[i];for(int i=0;i<n;i++)b[i]=a[i];for(int i=0;i<n;i++)if(b[i]=='V'&&a[i+1]=='K')ans++;tmp=ans;ans=0;for(int i=0;i<n;i++){if(b[i]=='V')b[i]='K';for(int i=0;i<n;i++)if(b[i]=='V'&&a[i+1]=='K')ans++;if(ans>tmp)tmp=ans;ans=0;b[i]=a[i];}cout<<tmp;return 0;} ```
by chanthu2114 @ 2022-10-04 13:19:20


```cpp #include <bits/stdc++.h> int main(){ int n,nowvk=0,temp=0; std::string vk; std::cin>>n>>vk; for(int i = 0 ; i < n ; i ++ ) if(i!=n-1) if(vk[i]=='V' && vk[i+1]=='K') nowvk++; for(int i = 0 ; i < n ; i ++ ){ if(vk[i]=='V') vk[i]='K'; else vk[i]='V'; for(int j=0;j<n;j++) if(j!=n-1) if(vk[j]=='V' && vk[j+1]=='K') temp++; if(temp>nowvk) nowvk=temp; temp=0; if(vk[i]=='K') vk[i]='V'; else vk[i]='K'; } std::cout<<nowvk; return 0; } ``` 试试这个 对了 ## https://www.luogu.com.cn/team/54136 加我团队吧 ## https://www.luogu.com.cn/team/54136 加我团队吧 ## https://www.luogu.com.cn/team/54136 加我团队吧
by mzh98K @ 2022-12-29 18:12:07


|