1 solutions
-
0
C++ :
#include <bits/stdc++.h> using namespace std; int a[210],b[201]; int main(){ string s1 = "",s2 = ""; int i,j,n,s,x = 0; cin>>n>>s; int c; for(i = 1;i <= n;i++){ s = (s * 345) % 19997; c = (97 + s % 26); //出现了就标记 a[c]++; } for(i = 1;i <= n;i++){ s = (s * 345) % 19997; c = (97 + s % 26); b[c]++; } //cout<<s1<<" "<<s2<<endl; //统计2个字符串不相同的字符的个数,就是代价(交换不消耗代价) //统计不相同的可以反过来统计相同的 for(i = 97;i < 97 + 26;i++){ if(a[i] != 0 && b[i] != 0){ x = x + min(a[i],b[i]); } } cout<<n - x; }
- 1
Information
- ID
- 10078
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By