-
Notifications
You must be signed in to change notification settings - Fork 1
/
DIVSTR.cpp
53 lines (45 loc) · 1.02 KB
/
DIVSTR.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// DIVSTR - Divisible Strings
// Author: Tarun Kumar
// E-mail: [email protected]
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define fab(i,a,b) for(i=a;i<=b;i++)
#define fabr(i,a,b) for(i=b;i>=a;i--)
using namespace std;
int main()
{
FAST;
ll t,n,i,j,k,l,p,q,r,ans,avg,sum,cnt,x;
char ch;
cin>>t;
cin.ignore();
while(t--)
{
string str,s;
getline(cin,str);
getline(cin,s);
if(str.size()==0||s.size()==0)
{
cout<<0<<"\n";
continue;
}
p=0;cnt=0;
fab(i,0,str.size()-1)
{
p%=s.size();
ch=s[p];
if(ch==str[i])
{
cnt++;
p++;
continue;
}
}
// cout<<cnt<<"\n";
x=cnt/s.size();
x*=s.size();
cout<<str.size()-x<<"\n";
}
return 0;
}