Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Brute force solution for DCE05 (Odd) gives WA

$
0
0
#include <stdio.h>
#include <math.h>
int main (void)
{
    int x, y, z;
    scanf ("%i", &x);
    for (x; x > 0; --x)
    {
        scanf ("%i", &y);
        if ( y == 0 )
        printf ("1\n");
        else if (y == 1)
        printf ("1\n");
        else if (y == 2 || y == 3)
        printf ("2\n");
        else if (y < 4 && y >= 2 )
        printf ("2\n"); 
        else if (y < 8 && y >= 4)
        printf ("4\n");
        else if (y < 16 && y >= 8)
        printf ("8\n");
        else if (y < 32 && y >= 16)
        printf ("16\n");
        else if (y < 64 && y >= 32)
        printf ("32\n");
        else if (y < 128 && y >= 64)
        printf ("64\n");
        else if (y < 256 && y >= 128)
        printf ("128\n");
        else if (y < 512 && y >= 256)
        printf ("256\n");
        else if (y < 1024 && y >= 512)
        printf ("512\n");
        else if (y < 2048 && y >= 1024)
        printf ("1024\n");
        else if (y < 4096 && y >= 2048)
        printf ("2048\n");
        else if (y < 8192 && y >= 4096)
        printf ("4096\n");
        else if (y < 16384 && y >= 8192)
        printf ("8192\n");
        else if (y < 32768 && y >= 16384)
        printf ("16384\n");
        else if (y < 65536 && y >= 32768)
        printf ("32768\n");
        else if (y < 131072 && y >= 65536)
        printf ("65536\n");
        else if (y < 262144 && y >= 131072)
        printf ("131072\n");
        else if (y < 524288 && y >= 262144)
        printf ("262144\n");
        else if (y < 1048576 && y >= 524288)
        printf ("524288\n");
        else if (y < 2097152 && y >= 1048576)
        printf ("1048576\n");
        else if (y < 4194304 && y >= 2097152)
        printf ("2097152\n");
        else if (y < 8388608 && y >= 4194304)
        printf ("4194304\n");
        else if (y < 16777216 && y >= 8388608)
        printf ("8388608\n");
        else if (y < 33554432 && y >= 16777216)
        printf ("16777216\n");
        else if (y < 67108864 && y >= 33554432)
        printf ("33554432\n");
        else if (y < 134217728 && y >= 67108864)
        printf ("67108864\n");
        else if (y < 268435456 && y >= 134217728)
        printf ("134217728\n");
        else if (y < 536870912 && y >= 268435456)
        printf ("268435456\n");
        else if (y < 1073741824 && y >= 536870912)
        printf ("536870912\n");
    }

    return 0;
}

Why is it giving wrong answer? I have compared the output of this program with another accepted solution. Both were identical. I am new to programming and hence I do not know about any algorithms. This is the best I could come up with.


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>