WSCIPHER

WSCIPHER

#include<iostream>
#include<cstring>

using namespace std;
int main()
{
int k1,k2,k3;
char a[200],k1a[200],k2a[200],k3a[200],temp1[200],temp2[200],temp3[200];

int l,m,n,p,q,r,t,s;
while(true)   
    {
               cin>>k1>>k2>>k3;
    if((k1==0)&&(k2==0)&&(k3==0))break;
    cin>>a;
    p=strlen(a);
    l=0,m=0,n=0,t=0;
    for(int x=0;x<p;x++)
    if((a[x]>96)&&(a[x]<106))
    k1a[l++]=a[x];          
    else if((a[x]>105)&&(a[x]<115))
    k2a[m++]=a[x];
  else
    k3a[n++]=a[x];                              
    k1a[l]='\0';    
    k2a[m]='\0';
    k3a[n]='\0';
  
    p=strlen(k1a);
    if(p>0)
    q=k1%p;else q=0;
    for(int ln=0;ln<p;ln++)
    temp1[(ln+q)%(strlen(k1a))]=k1a[ln];
  temp1[p]='\0';
  
    p=strlen(k2a);
    if(p>0)
   r=k2%p;else r=0;
    for(int ln=0;ln<p;ln++)
     temp2[(ln+r)%p]=k2a[ln];
    temp2[p]='\0';
    
     p=strlen(k3a);
     if(p>0)
    s=k3%p;else s=0;
    for(int ln=0;ln<p;ln++)
      temp3[(ln+s)%p]=k3a[ln];
  temp3[p]='\0';

l=0,m=0,n=0;
   p=strlen(a);
for(int x=0;x<p;x++)
    if((a[x]>96)&&(a[x]<106))
    a[x]=temp1[l++];          
    else if((a[x]>105)&&(a[x]<115))
    a[x]=temp2[m++];
  else
    a[x]=temp3[n++];

    cout<<a<<endl;
                                             
    }
    return 0;
}


YELBRICK

YELBRICK

#include<iostream>
using namespace std;
int min(int a,int b)
{
if(a<b)return a;
else return b;
}

int main()
{

int t;
cin>>t;

while(t!=0)
{
unsigned long long int vol;int minb=1001,mina;
int a[t],b[t],c[t];
for(int i=0;i<t;i++)
{
cin>>a[i]>>b[i]>>c[i];
mina = min(a[i],min(b[i],c[i]));
if((mina<minb)&&(mina>0))minb = mina;
}

unsigned long long int tt=0;
vol=(minb*minb*minb);
for(int i=0;i<t;i++)
{
tt+= (a[i]*b[i]*c[i])/vol;
}
cout<<tt<<endl;

cin>>t;
}


}

ZIGZAG

ZIGZAG

#include<iostream>
using namespace std;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    unsigned long long int x=0,y=0;
    unsigned long long int total=0;
    for(int i=0;i<k;i++)
    {
     char temp;
     cin>>temp;
    
     unsigned long long int res,len,test;
     if(temp=='U')x=x-1;
     if(temp=='D')x=x+1;
     if(temp=='L')y=y-1;
     if(temp=='R')y=y+1;
     if((x+y)&1)
     {
         if((x+y)<n)
         {
          res = (x+y)*(x+y+1)/2 + 1;
          res = res + x;
         
          total+=res;           
         }
         else
         {
              res = (x+y)*(x+y+1)/2 - ((x+y-n)*(x+y-n+1)) + 1;
              res = res + n -1 - y;
            
             total+=res;
         }    
     }
     else
     {
        
         if((x+y)<n)
         {
          res = (x+y)*(x+y+1)/2 + 1;
          res = res + y;
         
          total+=res;           
         
         }
         else
         {
            
            
              res = (x+y)*(x+y+1)/2 - ((x+y-n)*(x+y-n+1)) + 1;
        
              res = res + n - 1 - x;
             
              total+=res;
         }
     }      
    
           
    }
    cout<<total+1<<endl;   
   
    return 0;
}

FCTRL2

FCTRL2

#include<iostream>

#include<cstring>

int max = 5000;

void display(int arr[]){
    int ctr = 0;
    for (int i=0; i<max; i++){
        if (!ctr && arr[i])                     ctr = 1;
        if(ctr)
            std::cout<<arr[i];
    }
}


void factorial(int arr[], int n){
    if (!n) return;
    int carry = 0;
    for (int i=max-1; i>=0; --i){
        arr[i] = (arr[i] * n) + carry;
        carry = arr[i]/10;
        arr[i] %= 10;
    }
    factorial(arr,n-1);
}

int main(){
   
    int t;
    std::cin>>t;
    for(int j=0;j<t;j++){
            int *arr = new int[max];
    std::memset(arr,0,max*sizeof(int));
    arr[max-1] = 1;
    int num;
    std::cin>>num;
    factorial(arr,num);
    display(arr);
    std::cout<<"\n";
    delete[] arr;
}
   
    return 0;
}


FCTRL

FCTRL

#include<iostream>

#include<math.h>
using namespace std;

main()

{
      long int a,b,d,g,x,e,f,sum;
      long int c[100000];
  cin>>a;
  for(b=0;b<a;b++)
  {
                  cin>>c[b];   
      }
     
      for(b=0;b<a;b++)
      {
                      sum=0;
                      e=0;
                      f=1;
                      x=c[b];
                      g=pow(5,f);
                      while(x/g>0)
                      {
                                sum=sum+x/g;
                               
                                f++;        
                                g=pow(5,f);                             
                                          }
     
                     cout<<sum<<endl;
                   
                     
                      }

}

AMZSEQ

AMZSEQ

#include<iostream>
using namespace std;
typedef long long int int64;
int main()
{
 int64 arr[10000];
 arr[1] = 3;
 arr[2] = 7;
 int i = 2;
 while(arr[i]<1e10)
 {
  arr[i+1] = 2*arr[i] + arr[i-1];
  i++;                 
 }   
 int n;
 cin>>n;
 cout<<arr[n]<<endl;
}

ARMY

ARMY

#include<iostream>
using namespace std;
int main()
{ int t,ng,nm,sg,sm,maxg,maxm,flag;
 cin>>t;
while(t--)
 {cin>>ng>>nm;
 maxg=0;maxm=0;
 if(ng==0&&nm==0){cout<<"uncertain"<<endl;goto last;}
 else if(nm==0){cout<<"Godzilla"<<endl;goto last;}
 else if(ng==0){cout<<"MechaGodzilla"<<endl;goto last;}
  while(ng--)
  { cin>>sg;
  if(sg>maxg)maxg=sg;
  } 
  while(nm--)
  { cin>>sm;
  if(sm>maxm)maxm=sm;
  } 
         if(maxg>=maxm)cout<<"Godzilla"<<endl;
         else cout<<"MechaGodzilla"<<endl;
        
         last:;
         }
         return 0;
    }