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;
}