2014 in review


The WordPress.com stats helper monkeys prepared a 2014 annual report for this blog.

Here’s an excerpt:

The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 11,000 times in 2014. If it were a concert at Sydney Opera House, it would take about 4 sold-out performances for that many people to see it.

Click here to see the complete report.

UVa Solution 11172 – Relational Operator


The problem link is
 UVa:11172-Relational Operator

Difficulty Level : 0.5

Solution:

#include<stdio.h>
int main()
{
    int t,i;
    long a,b;
    scanf("%d",&t);
    if(t<15)
    {
        for(i=0;i<t;i++)
        {
            scanf("%ld %ld",&a,&b);
            if(a>b)
                printf(">\n");
            else if(a<b)
                printf("<\n");
            else
                printf("=\n");
        }
    }
    return 0;
}

Run time: 0.009
User Name on UVA: refatsardar

UVa Solution 10696 – f91


The problem link is
 UVa:10696-f91

Difficulty Level : 1.0

Solution:

#include<stdio.h>
int main()
{
    long n;
    while(scanf("%ld",&n)==1)
    {
        if(n==0)
            break;
        else if(n>=101)
            printf("f91(%ld) = %ld",n,n-10);
        else
            printf("f91(%ld) = 91",n);
        printf("\n");
    }
    return 0;
}

Run time: 0.076
User Name on UVA: refatsardar

UVa Solution 10302 – Summation of Polynomials


The problem link is
 UVa:10302-Summation of Polynomials

Difficulty Level : 0.5

Solution:

#include<stdio.h>
int main()
{
    long double sum,i;
    int n;
    while(scanf("%d",&n) == 1)
    {
        sum=0;
        for(i=1;i<=n;i++)
        {
            sum += i*i*i;
        }
        printf("%.0Lf\n",sum);
    }
    return 0;
}

Run time: 0.009
User Name on UVA: refatsardar

UVa Solution 272 – TEX Quotes


The problem link is
 UVa:272-TEX Quotes

Difficulty Level : 0.5

Solution:

#include <stdio.h>
#include <string.h>
int main()
{
    int i,end=0;
    char str[1000];
    while(gets(str))
    {
        for(i=0;i<strlen(str);i++)
        {
            if(str[i] == '"' && end == 0)
            {
                printf("``");
                end = 1;
            }
            else if(str[i] == '"' && end == 1)
            {
                printf("''");
                end = 0;
            }
            else
            {
                printf("%c",str[i]);
            }
        }
        printf("\n");
    }   
    return 0;
}

Run time: 0.009
User Name on UVA: refatsardar

UVa Solution 11150 – Cola


The problem link is
 UVa:11150-Cola

After some trial and error of sample input output, i have found the smallest solution.

Solution:

#include<stdio.h>
int main()
{
    int n,res = 0;
    while(scanf("%d",&n)==1)
    {
        res = n+(n/2);
        printf("%d\n",res);
    }
    return 0;
}

Run time: 0.009
User Name on UVA: refatsardar

UVa Solution 10970 – Big Chocolate


The problem link is
 UVa:10970-Big Chocolate

Solution:

#include<stdio.h>
int main()
{
    long m,n;
    while(scanf("%ld %ld",&m,&n)==2)
    {
        printf("%ld\n",m*n-1);
    }
    return 0;
}

Run time: 0.036
User Name on UVA: refatsardar