Sunday, November 20, 2011

UVa Problem: The Decoder (458)

//This C++ program is the solution to
//the problem put up on the UVa online judge
//website. The problem id is 458
//
//Question: The Decoder

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    char c;
    while((c=cin.get())!=EOF)
    {
                    if(c=='\n')
                    {
                               cout<<'\n';
                     }
                     else
                     {
                               cout<<(char)(((int)c)-7);
                     }         
    }
}

//Author of solution : Mayank Rajoria

Wednesday, October 26, 2011

UVa Problem: Ecological Premium(10300)

//This C++ program is the solution to
//the problem put up on the UVa online judge
//website. The problem id is 10300
//
//Question: Ecological Premium


#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int f,i,ar[n],j;
int a,b,c,s=0;
for(i=0;i<n;i++)
{
cin>>f;
s=0;
for(j=1;j<=f;j++)
{
cin>>a>>b>>c;
s=s+a*c;
}
ar[i]=s;
}

for(i=0;i<n;i++)
{
cout<<ar[i]<<"\n";
}
}

//Author of solution : Mayank Rajoria

UVa Problem: Hashmat the Brave Warrior(10055)

//This C++ program is the solution to
//the problem put up on the UVa online judge
//website. The problem id is 10055
//
//Question: Hashmat the brave warrior

#include<iostream>
using namespace std;
int main()
{
long a,b;
while(cin>>a>>b)
{
if(a>b)
{
cout<<a-b<<"\n";
}
else
{
cout<<b-a<<"\n";
}
}
}
//Author of solution : Mayank Rajoria