Posts

Codeforces solution 734A Anton and Danik

Image
#include<bits/stdc++.h> using namespace std; int main() {     int n,a=0,d=0;     char ch;     cin>>n;     for(int i=1; i<=n; i++)     {         cin>>ch;         if(ch=='A')         {             a++;         }         else         {             d++;         }     }     if(a>d)     {         cout<<"Anton"<<endl;     }     else if(d>a)     {         cout<<"Danik"<<endl;     }     else if(a==d)     {         cout<<"Friendship"<<endl;     } }

Uva solution 12468 Zapping

Image
#include<bits/stdc++.h> using namespace std; int main() {     int x,y,i,a=0,d=0,co=0;     while(1)     {         cin>>x>>y;         a=0;         d=0;         if(x==-1 && y==-1)         {             break;         }         if(x>y)         {             a=x-y;         }         if(y>x)         {             a=y-x;         }         d=100-a;         if(d>a)         {             cout<<a<<endl;         }         else //if(a>d) ...

Uva solution 12626 I ❤ Pizza

Image
#include<bits/stdc++.h> using namespace std; int main() {     int n,c1=0,c2=0,c3=0,c4=0,c5=0,c6=0,c=0,d;     char ch[1000];     cin>>n;     cin.ignore();     for(int j=1; j<=n; j++)     {         cin.getline(ch,1000);         c=0,c1=0,c2=0,c3=0,c4=0,c5=0,c6=0,d=0;         d=strlen(ch);         for(int i=0; i<d; i++)         {             if(ch[i]=='M')             {                 c1++;             }             else if(ch[i]=='A')             {                 c2++;             }             else if(...

Uva solution 13034 Solve Everything

Image
#include<bits/stdc++.h> using namespace std; int main() {     int n,x,arr,c=0;     cin>>n;     for(int j=1; j<=n; j++)     {         c=0;         for(int i=1; i<=13; i++)         {             cin>>arr;             if(arr>=1)             {                 c++;             }         }         if(c==13)         {             printf("Set #%d: Yes\n",j);         }         else         {             printf("Set #%d: No\n",j);         }     }     return 0; }

Uva solution 10696 f91

Image
#include<bits/stdc++.h> using namespace std; int f91(int n) {     int d;     if(n<=100)     {         return f91(f91(n + 11));     }     else if(n>=101)     {          return n-10;     } } int main() {     int n,m;     while(1)     {     cin>>n;     if(n==0)     {         return 0;     }     m=f91(n);     cout<<"f91("<<n<<") = "<<m<<endl;     }     return 0; }

Uva solution 10921 Find the Telephone

Image
#include<bits/stdc++.h> using namespace std; int main() {     int d;     char ch[1000];     while(!cin.getline(ch,1000).eof())     {         d=strlen(ch);         for(int i=0; i<d; i++)         {             if(ch[i]=='1')             {                 cout<<1;             }             if(ch[i]=='0')             {                 cout<<0;             }             if(ch[i]=='-')             {                 cout<<"-";             }       ...

Uva solution 10323 Factorial! You Must be Kidding!!!

Image
#include<stdio.h> long long int f(long long int n) {     if(n==0)     {         return 1;     }     else     {         return  n*f(n-1);     } } int main() {     long long int M,N,a,b,sum;     while(scanf("%lld",&M)!=EOF)     {         sum=0;         a=f(M);         sum=a;         if(sum > 6227020800)         {             printf("Overflow! %d\n",sum);         }         if(sum < 10000)         {             printf("Underflow! %d\n",sum);         }         else         {             printf("%lld\n",sum);...