Pages

Thursday 1 November 2012

UVA - 256 - Quirksome Squares (C solution)

#include <stdio.h>

int main()
{
    int x;
    while(scanf("%d",&x)==1){
        if(x==2)
            puts("00\n01\n81");
        else if(x==4)
            puts("0000\n0001\n2025\n3025\n9801");
        else if(x==6)
            puts("000000\n000001\n088209\n494209\n998001");
        else if(x==8)
            puts("00000000\n00000001\n04941729\n07441984\n24502500\n25502500\n52881984\n60481729\n99980001");
    }
    return 0;
}

2 comments:

  1. how i can find the number...................????

    ReplyDelete
    Replies
    1. one solution is to brute force and then hard code the answer to get better run-time and memory consumption as the input is limited ...

      Delete