Masala #EYOHITOMXF
Optimizatsiya
#include <bits/stdc++.h>
using namespace std;
main() {
string s, t;
cin >> s >> t;
int c = 0;
for (int i = 0; i <= s.length() - t.length(); i++) {
for (int j = 0; j < t.length(); j++) {
if (s[i + j] != t[j]) {
c++;
}
}
}
cout << c;
}
s = input()
t = input()
c = 0
for i in range(len(s) - len(t) + 1):
for j in range(len(t)):
if s[i + j] != t[j]:
c += 1
print(c)
Kiruvchi ma'lumotlar:
BIrinchi qator \(S\) satri \(|S|(1≤|S|≤10^5).\)
Chiquvchi ma'lumotlar:
Shu kodni natijasini ekranga chiqarish.
Misollar
# | input.txt | output.txt |
---|---|---|
1 |
plbmbhtztalz lufi |
35 |
2 |
bqqupo s |
6 |
Izoh:
Pythonda ishlasangiz PyPy dan foydalanishingizni tavsiya qilaman.