Wednesday, February 9, 2011

913 - Joana and the Odd Numbers


#include<stdio.h>

typedef long long LONG;

int main()
{
    LONG m,n,i,sum;
    //freopen("in.txt","r",stdin);

    while(scanf("%lld",&n)==1)
    {
        i=(n+1)/2;//i is line no where n odd numbers exist

        m=n*i+i-1;//Last number of line i is m

        sum=(m-2)*3;

        printf("%lld\n",sum);
    }
    return 0;
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.