Skip to content

Commit ddf99aa

Browse files
committed
practice 20-Jan-2020
1 parent fd0270c commit ddf99aa

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
ios_base::sync_with_stdio(false);
7+
cin.tie(NULL);
8+
string s;
9+
cin>>s;
10+
int n=s.length();
11+
int ca=0;
12+
for(int i=0;i<n;i++){
13+
if(s[i]=='a') ca++;
14+
}
15+
int other=n-ca;
16+
if(n==0) cout<<n;
17+
else if(ca>other) cout<<n;
18+
else if(ca<=other)
19+
cout<<ca+ca-1;
20+
21+
return 0;
22+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main()
7+
{
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(NULL);
10+
int t;
11+
cin>>t;
12+
while(t--){
13+
string s;
14+
cin>>s;
15+
char ch=s[s.length()-1];
16+
switch(ch){
17+
case 'o': cout<<"FILIPINO\n"; break;
18+
case 'u': cout<<"JAPANESE\n"; break;
19+
case 'a': cout<<"KOREAN\n"; break;}
20+
}
21+
22+
23+
return 0;
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
ios_base::sync_with_stdio(false);
7+
cin.tie(NULL);
8+
int n;
9+
cin>>n;
10+
string s;
11+
cin>>s;
12+
int cf=0,cs=0;
13+
for(int i=0;i<n-1;i++){
14+
if(s[i]!=s[i+1]){
15+
if(s[i]=='F') cf++;
16+
else cs++;
17+
}
18+
}
19+
if(cs>cf) cout<<"YES";
20+
else cout<<"NO";
21+
22+
return 0;
23+
}

0 commit comments

Comments
 (0)