Problem link (Click here)
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
int cases=0;
string str;
while(1)
{
cases++;
cin>>str;
if(str=="*")
break;
else if( str=="Hajj")
printf("Case %d: Hajj-e-Akbar\n", cases);
else
printf("Case %d: Hajj-e-Asghar\n", cases);
}
return 0;
}
Saturday, April 30, 2016
UVA problem 11799 - Horror Dash
Problem link (Click here)
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int test_case,n,i,a,c=0;
cin >> test_case;
while(test_case--)
{
c++;
int max=0;
cin>>n;
for(i=0;i<n;i++){
cin>>a;
if(a>max)
max=a;
}
cout <<"Case "<< c <<": "<<max<<endl;
}
return 0;
}
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int test_case,n,i,a,c=0;
cin >> test_case;
while(test_case--)
{
c++;
int max=0;
cin>>n;
for(i=0;i<n;i++){
cin>>a;
if(a>max)
max=a;
}
cout <<"Case "<< c <<": "<<max<<endl;
}
return 0;
}
UVA problem 10082 - WERTYU
Problem link (Click here)
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
int l,i;
char s[100000];
while(gets(s))
{
l=strlen(s);
for(i=0;i<l;i++)
{
if(s[i]=='W')
printf("Q");
else if (s[i]=='E')
printf("W");
else if (s[i]=='R')
printf("E");
else if (s[i]=='T')
printf("R");
else if (s[i]=='Y')
printf("T");
else if (s[i]=='U')
printf("Y");
else if (s[i]=='I')
printf("U");
else if (s[i]=='O')
printf("I");
else if (s[i]=='P')
printf("O");
else if (s[i]=='[')
printf("P");
else if (s[i]==']')
printf("[");
else if (s[i]=='\\')
printf("]");
else if (s[i]=='S')
printf("A");
else if (s[i]=='D')
printf("S");
else if (s[i]=='F')
printf("D");
else if (s[i]=='G')
printf("F");
else if (s[i]=='H')
printf("G");
else if (s[i]=='J')
printf("H");
else if (s[i]=='K')
printf("J");
else if (s[i]=='L')
printf("K");
else if (s[i]==';')
printf("L");
//else if (s[i]==''')
else if (s[i]=='X')
printf("Z");
else if (s[i]=='C')
printf("X");
else if (s[i]=='V')
printf("C");
else if (s[i]=='B')
printf("V");
else if (s[i]=='N')
printf("B");
else if (s[i]=='M')
printf("N");
else if (s[i]==',')
printf("M");
else if (s[i]=='.')
printf(",");
else if (s[i]=='/')
printf(".");
else if (s[i]=='1')
printf("`");
else if (s[i]=='2')
printf("1");
else if (s[i]=='3')
printf("2");
else if (s[i]=='4')
printf("3");
else if (s[i]=='5')
printf("4");
else if (s[i]=='6')
printf("5");
else if (s[i]=='7')
printf("6");
else if (s[i]=='8')
printf("7");
else if (s[i]=='9')
printf("8");
else if (s[i]=='0')
printf("9");
else if (s[i]=='-')
printf("0");
else if (s[i]=='=')
printf("-");
else if (s[i]==' ')
printf(" ");
else
printf(";");
}
printf("\n");
}
return 0;
}
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
int l,i;
char s[100000];
while(gets(s))
{
l=strlen(s);
for(i=0;i<l;i++)
{
if(s[i]=='W')
printf("Q");
else if (s[i]=='E')
printf("W");
else if (s[i]=='R')
printf("E");
else if (s[i]=='T')
printf("R");
else if (s[i]=='Y')
printf("T");
else if (s[i]=='U')
printf("Y");
else if (s[i]=='I')
printf("U");
else if (s[i]=='O')
printf("I");
else if (s[i]=='P')
printf("O");
else if (s[i]=='[')
printf("P");
else if (s[i]==']')
printf("[");
else if (s[i]=='\\')
printf("]");
else if (s[i]=='S')
printf("A");
else if (s[i]=='D')
printf("S");
else if (s[i]=='F')
printf("D");
else if (s[i]=='G')
printf("F");
else if (s[i]=='H')
printf("G");
else if (s[i]=='J')
printf("H");
else if (s[i]=='K')
printf("J");
else if (s[i]=='L')
printf("K");
else if (s[i]==';')
printf("L");
//else if (s[i]==''')
else if (s[i]=='X')
printf("Z");
else if (s[i]=='C')
printf("X");
else if (s[i]=='V')
printf("C");
else if (s[i]=='B')
printf("V");
else if (s[i]=='N')
printf("B");
else if (s[i]=='M')
printf("N");
else if (s[i]==',')
printf("M");
else if (s[i]=='.')
printf(",");
else if (s[i]=='/')
printf(".");
else if (s[i]=='1')
printf("`");
else if (s[i]=='2')
printf("1");
else if (s[i]=='3')
printf("2");
else if (s[i]=='4')
printf("3");
else if (s[i]=='5')
printf("4");
else if (s[i]=='6')
printf("5");
else if (s[i]=='7')
printf("6");
else if (s[i]=='8')
printf("7");
else if (s[i]=='9')
printf("8");
else if (s[i]=='0')
printf("9");
else if (s[i]=='-')
printf("0");
else if (s[i]=='=')
printf("-");
else if (s[i]==' ')
printf(" ");
else
printf(";");
}
printf("\n");
}
return 0;
}
UVA problem 12372 - Packing for Holiday
Problem link (Click here)
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int test_case, L, W, H, c = 0;
cin >> test_case;
while(test_case--)
{
cin >> L>>W>>H;
c++;
if(L>20||W>20||H>20)
cout <<"Case "<< c <<": "<<"bad"<<endl;
else
cout <<"Case "<< c <<": "<<"good"<<endl;
}
return 0;
}
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int test_case, L, W, H, c = 0;
cin >> test_case;
while(test_case--)
{
cin >> L>>W>>H;
c++;
if(L>20||W>20||H>20)
cout <<"Case "<< c <<": "<<"bad"<<endl;
else
cout <<"Case "<< c <<": "<<"good"<<endl;
}
return 0;
}
UVA problem 272 - TEX Quotes
Problem link (Click here)
#include<iostream>
#include<stdio.h>
#include <string.h>
using namespace std;
int main()
{
char s[1000];
int count = 0;
int a;
while (gets(s))
{
a=strlen(s);
for(int i = 0; i < a; i++)
{
if(s[i] == '"'){
count++;
if(count%2==0)
printf("''");
else
printf("``");
}
else
printf("%c",s[i]);
}
printf("\n");
}
return 0;
}
#include<iostream>
#include<stdio.h>
#include <string.h>
using namespace std;
int main()
{
char s[1000];
int count = 0;
int a;
while (gets(s))
{
a=strlen(s);
for(int i = 0; i < a; i++)
{
if(s[i] == '"'){
count++;
if(count%2==0)
printf("''");
else
printf("``");
}
else
printf("%c",s[i]);
}
printf("\n");
}
return 0;
}
UVA problem 1124 - Celebrity jeopardy
Problem link (Click here)
#include <cstdio>
using namespace std;
int main()
{
char a[100];
while(gets(a))
puts(a);
return 0;
}
#include <cstdio>
using namespace std;
int main()
{
char a[100];
while(gets(a))
puts(a);
return 0;
}
Friday, April 29, 2016
CODEFORCES problem 118B-Present from Lena
Problem link (Click here)
#include<iostream>
using namespace std;
int main()
{
int i, j, k, l, n;
cin >> n;
for(i=0;i<=n;i++)
{
for(j=i;j<n;j++)
cout<<" ";
for(k=0;k<=i;k++){
cout << k;
if(i!=0)
cout << " ";
}
for(k=i-1;k>=0;k--){
cout<<k;
if(k>0)
cout<<" ";
}
cout<<"\n";
}
for(i=n-1;i>=0;i--)
{
for(j=n-1;j>=i;j--)
cout<<" ";
for(k=0;k<=i;k++){
cout << k;
if(i!=0)
cout << " ";
}
for(k=i-1;k>=0;k--){
cout<<k;
if(k>0)
cout<<" ";
}
cout<<"\n";
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int i, j, k, l, n;
cin >> n;
for(i=0;i<=n;i++)
{
for(j=i;j<n;j++)
cout<<" ";
for(k=0;k<=i;k++){
cout << k;
if(i!=0)
cout << " ";
}
for(k=i-1;k>=0;k--){
cout<<k;
if(k>0)
cout<<" ";
}
cout<<"\n";
}
for(i=n-1;i>=0;i--)
{
for(j=n-1;j>=i;j--)
cout<<" ";
for(k=0;k<=i;k++){
cout << k;
if(i!=0)
cout << " ";
}
for(k=i-1;k>=0;k--){
cout<<k;
if(k>0)
cout<<" ";
}
cout<<"\n";
}
return 0;
}
UVA problem 11172 – Relational Operator
Problem link (Click here)
#include<iostream>
using namespace std;
int main ()
{
int i, t, a, b;
cin>>t;
for(i=0; i<t; i++){
cin>>a>>b;
if(a<b)
cout<<'<'<<endl;
else if (a>b)
cout<<'>'<<endl;
else
cout<<'='<<endl;
}
return 0;
}
#include<iostream>
using namespace std;
int main ()
{
int i, t, a, b;
cin>>t;
for(i=0; i<t; i++){
cin>>a>>b;
if(a<b)
cout<<'<'<<endl;
else if (a>b)
cout<<'>'<<endl;
else
cout<<'='<<endl;
}
return 0;
}
UVA problem 10300 – Ecological Premium
Problem link (Click here)
#include <stdio.h>
int main()
{
long long a,b,c,m,n,i;
scanf("%lld",&m);
while(m--){
scanf("%lld",&n);
long long sum=0;
for(i=0;i<n;i++){
scanf("%lld %lld %lld",&a, &b, &c);
sum=sum+a*c;
}
printf("%lld\n",sum);
}
return 0;
}
#include <stdio.h>
int main()
{
long long a,b,c,m,n,i;
scanf("%lld",&m);
while(m--){
scanf("%lld",&n);
long long sum=0;
for(i=0;i<n;i++){
scanf("%lld %lld %lld",&a, &b, &c);
sum=sum+a*c;
}
printf("%lld\n",sum);
}
return 0;
}
UVA problem 100 – The 3n + 1
Problem link (click here)
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
int i, j;
int c,d;
while(scanf("%d",&i)!= EOF){
int max=0;
scanf("%d",&j);
c=i;
d=j;
if(i>j){
swap(i,j);
}
int k,n;
for(k=i;k<=j;k++){
int lenth=1;
n=k;
while(n!=1){
if (n%2!=0){
n=3*n+1;
}
else
n=n/2;
lenth++;
}
if(max<lenth){
max=lenth;
}
}
printf("%d %d %d\n",c,d,max);
}
return 0;
}
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
int i, j;
int c,d;
while(scanf("%d",&i)!= EOF){
int max=0;
scanf("%d",&j);
c=i;
d=j;
if(i>j){
swap(i,j);
}
int k,n;
for(k=i;k<=j;k++){
int lenth=1;
n=k;
while(n!=1){
if (n%2!=0){
n=3*n+1;
}
else
n=n/2;
lenth++;
}
if(max<lenth){
max=lenth;
}
}
printf("%d %d %d\n",c,d,max);
}
return 0;
}
UVA problem 10055 – Hashmat the Brave Warrior
Problem link (Click here)
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
long long i, j, d;
while(cin >> i){
cin >> j;
if(i>j)
swap(i,j);
cout << j-i <<endl;
}
return 0;
}
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
long long i, j, d;
while(cin >> i){
cin >> j;
if(i>j)
swap(i,j);
cout << j-i <<endl;
}
return 0;
}
UVA problem 10071 – Back to High School Physics
Problem link (Click here)
#include<stdio.h>
int main()
{
int v,t;
while(scanf("%d",&v)!=EOF){
scanf("%d",&t);
if(v==0&& t==0)
printf("0\n");
else
printf("%d\n",2*v*t);
}
return 0;
}
#include<stdio.h>
int main()
{
int v,t;
while(scanf("%d",&v)!=EOF){
scanf("%d",&t);
if(v==0&& t==0)
printf("0\n");
else
printf("%d\n",2*v*t);
}
return 0;
}
URI Problem 1018-Banknotes
Problem link (Click here)
#include <stdio.h>
int main()
{
int input , hundred ,fifty , twenty , ten ,five , two ,one ;
scanf("%d",&input);
hundred=(input/100);
fifty= (input-(hundred*100))/50;
twenty=(input-((hundred*100)+(fifty*50)))/20;
ten=(input-((twenty*20)+(fifty*50)+(hundred*100)))/10;
five=(input-((ten*10)+(twenty*20)+(fifty*50)+(hundred*100)))/5;
two=(input-((five*5)+(ten*10)+(twenty*20)+(fifty*50)+(hundred*100)))/2;
one=input-((two*2)+(five*5)+(ten*10)+(twenty*20)+(fifty*50)+(hundred*100));
printf("%d\n",input);
printf("%d nota(s) de R$ 100,00\n",hundred);
printf("%d nota(s) de R$ 50,00\n",fifty);
printf("%d nota(s) de R$ 20,00\n",twenty);
printf("%d nota(s) de R$ 10,00\n",ten);
printf("%d nota(s) de R$ 5,00\n",five);
printf("%d nota(s) de R$ 2,00\n",two);
printf("%d nota(s) de R$ 1,00\n",one);
return 0;
}
#include <stdio.h>
int main()
{
int input , hundred ,fifty , twenty , ten ,five , two ,one ;
scanf("%d",&input);
hundred=(input/100);
fifty= (input-(hundred*100))/50;
twenty=(input-((hundred*100)+(fifty*50)))/20;
ten=(input-((twenty*20)+(fifty*50)+(hundred*100)))/10;
five=(input-((ten*10)+(twenty*20)+(fifty*50)+(hundred*100)))/5;
two=(input-((five*5)+(ten*10)+(twenty*20)+(fifty*50)+(hundred*100)))/2;
one=input-((two*2)+(five*5)+(ten*10)+(twenty*20)+(fifty*50)+(hundred*100));
printf("%d\n",input);
printf("%d nota(s) de R$ 100,00\n",hundred);
printf("%d nota(s) de R$ 50,00\n",fifty);
printf("%d nota(s) de R$ 20,00\n",twenty);
printf("%d nota(s) de R$ 10,00\n",ten);
printf("%d nota(s) de R$ 5,00\n",five);
printf("%d nota(s) de R$ 2,00\n",two);
printf("%d nota(s) de R$ 1,00\n",one);
return 0;
}
Subscribe to:
Comments (Atom)