MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

GeeksForGeeks/Arya_Long_String/Solution.cpp:4–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2using namespace std;
3
4int main()
5{
6 int t; // t is the no. of test cases
7 cin>>t;
8 while(t--)
9 {
10 string s;
11 cin>>s;
12 int k,n;
13 cin>>k>>n;
14 char c; // c is the character whose occurence need to be counted
15 cin>>c;
16 int ext=n%s.size(); // extra string left
17 int count=0;
18 for(int i=0;i<ext;i++) // count occurence of character in extra string
19 {
20 if(s[i]==c)
21 count++;
22 }
23 int c1=0;
24 for(int i=0;i<s.size();i++) // count occurence of character in main string
25 {
26 if(s[i]==c)
27 c1++;
28 }
29 cout<<c1*(n/s.size())+count<<endl; // occurence in main string repeated (n/>s.size()) times and extra string
30 }
31
32 return 0;
33}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected