Tuesday, November 12, 2013
Sunday, November 10, 2013
UVA SOLUTION
LIST OF UVA PROBLEM SOLUTION
UVA10018 Reverse and Add SOLUTION DOWNLOAD
LIGHTOJ1000 - Greetings from LightOJ
Get paid to share your links!
1000 - Greetings from LightOJ
Solution:
#include < iostream >
using namespace std;
int main(){
int a,b,sum,t,cases=0;
cin>>t;
while(t--){
cin>>a>>b;
cout<< "Case " << ++cases << ": " << a+b << endl;
}
}
Problem & Solution Download
Saturday, November 9, 2013
LIGHTOJ1294 - Positive Negative Sign
1294 - Positive Negative Sign
Problem Link:
Solution:
#include < stdio.h >
int main(){
int t, cases=0;
long long int a, n, m;
scanf("%d",&t);
while(t--){
scanf("%lld %lld", &n, &m);
n = n/2;
m = m*n;
printf("Case %d: %lld\n",++cases,m);
}
return 0;
}
int main(){
int t, cases=0;
long long int a, n, m;
scanf("%d",&t);
while(t--){
scanf("%lld %lld", &n, &m);
n = n/2;
m = m*n;
printf("Case %d: %lld\n",++cases,m);
}
return 0;
}
Friday, November 8, 2013
UVA10346 - Peter's Smokes
10346 - Peter's Smokes
Solution:
#include < stdio.h >
int main()
{
int n,k,b,a;
while(scanf("%d %d",&n,&k)==2)
{
b=n;
while(n>=k)
{
b=b+n/k;
n=(n/k)+(n%k);
}
printf("%d\n",b);
}
}
Problem & Solution Download
int main()
{
int n,k,b,a;
while(scanf("%d %d",&n,&k)==2)
{
b=n;
while(n>=k)
{
b=b+n/k;
n=(n/k)+(n%k);
}
printf("%d\n",b);
}
}
Problem & Solution Download
UVA12502 - Three Families
12502 - Three Families
Solution:
#include < stdio.h >
int main(){
int t,a,b,c;
int Totalworkhours, Totalworkminute, eachworkminute, extraminute, Aget;
scanf("%d",&t);
while(t--){
scanf("%d %d %d",&a,&b,&c);
Totalworkhours = a+b;
Totalworkminute = Totalworkhours * 60;
eachworkminute = Totalworkminute/3;
extraminute = a * 60 - eachworkminute;
Aget = (c * extraminute)/eachworkminute;
if(Aget<=0)
printf("0\n");
else
printf("%d\n",Aget);
}
}
int main(){
int t,a,b,c;
int Totalworkhours, Totalworkminute, eachworkminute, extraminute, Aget;
scanf("%d",&t);
while(t--){
scanf("%d %d %d",&a,&b,&c);
Totalworkhours = a+b;
Totalworkminute = Totalworkhours * 60;
eachworkminute = Totalworkminute/3;
extraminute = a * 60 - eachworkminute;
Aget = (c * extraminute)/eachworkminute;
if(Aget<=0)
printf("0\n");
else
printf("%d\n",Aget);
}
}
UVA10018 - Reverse and Add
10018 - Reverse and Add
Solution:
#include < stdio.h >
int main()
{
long long int t,n,d,c,r,sum;
scanf("%lld",&t);
while(t--)
{
scanf("%lld",&n);
d=n;
c=0;
while(1)
{
sum=0;
while(d>0)
{
r=d%10;
sum=sum*10+r;
d=d/10;
}
if(n==sum)
break;
else
{
d=sum+n;
n=sum+n;
c++;
}
}
printf("%lld %lld\n",c,sum);
}
}
Problem & Solution Download
int main()
{
long long int t,n,d,c,r,sum;
scanf("%lld",&t);
while(t--)
{
scanf("%lld",&n);
d=n;
c=0;
while(1)
{
sum=0;
while(d>0)
{
r=d%10;
sum=sum*10+r;
d=d/10;
}
if(n==sum)
break;
else
{
d=sum+n;
n=sum+n;
c++;
}
}
printf("%lld %lld\n",c,sum);
}
}
Problem & Solution Download
UVA11854 - Egypt
11854 - Egypt
Solution:
#include < stdio.h >
int main()
{
int a,b,c;
while(scanf("%d %d %d",&a,&b,&c)==3)
{
if(a==0&&b==0&&c==0)
break;
if(a<=0||b<=0||c<=0)
printf("wrong\n");
else if(a*a==b*b+c*c)
printf("right\n");
else if(b*b==a*a+c*c)
printf("right\n");
else if(c*c==b*b+a*a)
printf("right\n");
else
printf("wrong\n");
}
}
Problem & Solution Download
int main()
{
int a,b,c;
while(scanf("%d %d %d",&a,&b,&c)==3)
{
if(a==0&&b==0&&c==0)
break;
if(a<=0||b<=0||c<=0)
printf("wrong\n");
else if(a*a==b*b+c*c)
printf("right\n");
else if(b*b==a*a+c*c)
printf("right\n");
else if(c*c==b*b+a*a)
printf("right\n");
else
printf("wrong\n");
}
}
Problem & Solution Download
Thursday, November 7, 2013
UVA11172 - Relational Operator
11172 - Relational Operator
Solution:
#include < stdio.h >
int main(){
int t, a,b;
scanf("%d",&t);
while(t--){
scanf("%d %d",&a,&b);
if(a < b)
printf("<");
else if(a > b)
printf(">");
else if(a == b)
printf("=");
printf("\n");
}
}
int main(){
int t, a,b;
scanf("%d",&t);
while(t--){
scanf("%d %d",&a,&b);
if(a < b)
printf("<");
else if(a > b)
printf(">");
else if(a == b)
printf("=");
printf("\n");
}
}
Wednesday, November 6, 2013
ACM HDU Problem Solution 1089-A+B for Input-Output Practice (I)
Problem 1089
A+B for Input-Output Practice (I)
Solution:
#include < stdio.h >int main(){
int a,b;
while(scanf("%d %d",&a,&b)==2){
printf("%d\n",a+b);
}
return 0;
}
Tuesday, November 5, 2013
ACM HDU Problem Solution 1001 - Sum Problem
Problem 1001 - Sum Problem
Solution:
int main(){
int n,sum,p;
while(scanf("%d",&n)==1){
sum=0;
for(p=1;p<=n;p++)
sum = sum + p;
printf("%d\n\n",sum);
}
return 0;
}
ACM HDU Problem Solution 1000 - A + B Problem
Problem 1000 - A + B Problem
#include<stdio.h>int main(){
int a,b;
while(scanf("%d %d",&a,&b)==2){
printf("%d\n",a+b);
}
return 0;
}
Subscribe to:
Posts (Atom)