- #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;
- }
Codeforces Solutions
Codeforces Solutions in C,C++,Python 3
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;
- }
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> 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 , l = 0 ; char a [ 120 ]; scanf ( ...
-
#include <stdio.h> #include <string.h> int main () { int i , n , p = 0 ; char s [ 120 ]; scanf ( ...