- #include <stdio.h>
- int main()
- {
- char ch[106];
- int i,j,ck=1;
- scanf("%s",ch);
- for(i=1;ch[i]!='\0';i++)
- {
- if(ch[i]>=97&&ch[i]<=122)
- {
- ck=0;
- break;
- }
- }
- if(ck==1)
- {
- if(ch[0]>=65&&ch[0]<=90)
- ch[0]=ch[0]+32;
- else
- ch[0]=ch[0]-32;
- for(j=1;ch[j]!='\0';j++)
- {
- ch[j]=ch[j]+32;
- }
- }
- printf("%s\n",ch);
- return 0;
- }
Wednesday, January 22, 2020
Codeforces 131A cAPS lOCK Solution in C
Tuesday, January 21, 2020
Codeforces 133A HQ9+ Solution in C
- #include<stdio.h>
- #include<string.h>
- int main()
- {
- int i,n,p=0;
- char s[120];
- scanf("%s",s);
- n=strlen(s);
- for (i=0;i<n;i++)
- {
- if (s[i]=='H' || s[i]=='Q' || s[i]=='9')
- {
- p++;break;
- }
- }
- if (p>0) printf("YES\n");
- else printf("NO\n");
- return 0;
- }
Codeforces 160A Twins Solution in C
- /// OmShantihari
- /// Author: Sujan Mridha
- /// CSE 5th batch, University of Barishal
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main ()
- {
- int i,n,m,b,c,s,a[200];
- cin>>n;
- for (i=0,s=0;i<n;i++)
- {
- cin>>a[i];
- s+=a[i];
- }
- sort (a,a+n);
- s/=2;
- for (i=n-1,c=0,b=0;i>=0;b++,i--)
- {
- c+=a[i];
- if (c>s) break;
- }
- cout<<++b<<endl;
- return 0;
- }
Codeforces 158B Taxi Solution in C++
- #include <iostream >
- using namespace std;
- int main()
- {
- int n,m,g1=0,g2=0,g3=0,s=0;
- cin>>n;
- for (int i=0;i<n;i++)
- {
- cin>>m;
- if (m==4) s++;
- else if (m==3) g3++;
- else if (m==2) g2++;
- else g1++;
- }
- g1-=g3;
- s+=g3;
- if (g2%2==0 && g2>0)
- {
- s+=g2/2;
- g2=0;
- }
- else if (g2%2==1 && g2>0)
- {
- s+=g2/2+1;
- g1-=2;
- }
- if (g1>0)
- {
- s+=g1/4;
- if (g1%4>0) s++;
- }
- cout<<s<<endl;
- return 0;
- }
Codeforces 546A Soldier and Bananas Solution in C
- #include<stdio.h>
- int main()
- {
- int i,a,c;
- long int b,x=0;
- scanf("%d%ld%d",&a,&b,&c);
- for (i=1;i<=c;i++)
- {
- x=x+i*a;
- }
- if (x>b) printf("%ld\n",x-b);
- else printf("0\n");
- return 0;
- }
Codeforces 116A Tram Solution in C++
- ///SMS
- #include <iostream>
- using namespace std;
- int main ()
- {
- int i,j,a,b,x=0,y=0,n,s=0;
- cin>>n;
- for (i=0;i<n;i++)
- {
- cin>>a>>b;
- x-=a;
- x+=b;
- if (x>s) s=x;
- }
- cout<<s<<endl;
- return 0;
- }
Codeforces 122A Lucky Division Solution in C
- ///SHS
- #include <iostream>
- using namespace std;
- int main ()
- {
- int i,j,k,a[]={4,7,44,47,77,444,447,477,777};
- cin>>k;
- for (i=0;i<9;i++)
- {
- if (k%a[i]==0)
- {
- cout<<"YES"<<endl;
- return 0;
- }
- }
- cout<<"NO"<<endl;
- return 0;
- }
Codeforces 58A Chat room Solution in C
- #include<stdio.h>
- #include<string.h>
- int main()
- {
- int i,n,l=0;
- char a[120];
- scanf("%s",a);
- n=strlen(a);
- for (i=0;i<n;i++)
- {
- if (a[i]=='h' && l==0) l++;
- else if (a[i]=='e' && l==1) l++;
- else if (a[i]=='l' && l==2) l++;
- else if (a[i]=='l' && l==3) l++;
- else if (a[i]=='o' && l==4) l++;
- if (l==5) break;
- }
- if (l==5) printf("YES\n");
- else printf("NO\n");
- return 0;
- }
Codeforces 69A Young Physicist Solution in C
- #include<stdio.h>
- int main()
- {
- int o,n,a,b,c,s,t,u;
- s=0;
- t=0;
- u=0;
- scanf("%d",&n);
- for (o=0; o<n; o++)
- {
- scanf("%d %d %d",&a,&b,&c);
- s=s+a;
- t=t+b;
- u=u+c;
- }
- if (s==0 && t==0 && u==0) printf("YES\n");
- else printf("NO\n");
- return 0;
- }
Codeforces 236A Boy or Girl Solution in C++
- ///SHS
- #include <iostream>
- #include <cstring>
- using namespace std;
- int main ()
- {
- int i,n,m=0,x[124]={0};
- char s[200];
- cin>>s;
- n= strlen (s);
- for (i=0;i<n;i++) x[s[i]]++;
- for (i=0;i<124;i++) if (x[i]>0) m++;
- if (m%2==1) cout<<"IGNORE HIM!";
- else cout<<"CHAT WITH HER!";
- return 0;
- }
Codeforces 266A Stones on the Table Solution in C
- #include <iostream>
- using namespace std;
- int main ()
- {
- int n,s=0;
- string m;
- cin>>n>>m;
- if (n==1)
- {
- cout<<"0"<<endl;
- return 0;
- }
- for (int i=0;i<n-1;i++)
- {
- if (m[i]==m[i+1]) s++;
- }
- cout<<s<<endl;
- return 0;
- }
Codeforces 263A Beautiful Matrix Solution in C
- #include<stdio.h>
- int main()
- {
- int mat[5][5], i , j, l, count = 0 , m, n;
- for(i = 0; i < 5; i++){
- for(j = 0; j < 5; j++){
- scanf("%d", &mat[i][j]);
- }
- }
- for(i = 0; i < 5; i++){
- for(j = 0; j < 5 ; j++){
- if(mat[i][j] == 1){
- m = i;
- n = j;
- break;
- }
- }
- }
- for( l = 0; l < 5; l++){
- if( n > 2){
- n = n - 1;
- count++;
- }
- else if (n == 2){
- break;
- }
- else if( n < 2){
- n = n + 1;
- count++;
- }
- }
- for( l = 0; l < 5; l++){
- if( m > 2){
- m = m - 1;
- count++;
- }
- else if (m == 2){
- break;
- }
- else if( m < 2){
- m = m + 1;
- count++;
- }
- }
- printf("%d\n", count);
- return 0;
- }
Codeforces 281A Word Capitalization Solution in C
- #include<stdio.h>
- #include<string.h>
- int main()
- {
- char n[3500];
- scanf("%s",&n);
- if (n[0]>='a' && n[0]<='z') n[0]=n[0]-32;
- printf("%s\n",n);
- return 0;
- }
Subscribe to:
Posts (Atom)
Codeforces 131A cAPS lOCK Solution in C
#include <stdio.h> int main () { char ch [ 106 ]; int i , j , ck = 1 ; scanf ( "%s" , ch ); ...
-
#include <stdio.h> #include <string.h> int main () { int i , n , l = 0 ; char a [ 120 ]; scanf ( ...
-
#include <stdio.h> int main () { int o , n , a , b , c , s , t , u ; s = 0 ; t = 0 ; u = 0 ...
-
#include <stdio.h> #include <string.h> int main () { int i , n , p = 0 ; char s [ 120 ]; scanf ( ...