You are not logged in. Please login at www.codechef.com to post your questions!

×

Whats wrong in this code?

#include <iostream>
using namespace std;

int t,n[1000];
void input(int);
void output(int);

int main()
{

    cin>>t;
    input(t);
    output(t);

    return 0;
}

void input(int t)
{

    {
        for (int i=0; i<t;i++)
            cin>>n[i];
    }
}

void output(int t)
{
    int temp=0, ans;
    int i=0;

    {
        for (i=0; i<t ; i++)
        {

            temp = n[i];
            ans=0;
            while (temp>=1 && temp<=100000)
            {
                int r=temp%10 ;
                ans=(ans*10) + r;
                temp=temp/10 ;
            }
            cout << ans <<endl;
        }
    }
}

asked 13 Jun, 17:11

mohitkhetan's gravatar image

0★mohitkhetan
1
accept rate: 0%

edited 13 Jun, 17:56

vijju123's gravatar image

5★vijju123 ♦
13.6k11036

Question code?

(13 Jun, 17:20) abhineet145★

which question are u trying to solve?

link

answered 13 Jun, 17:33

babu1998's gravatar image

1★babu1998
111
accept rate: 0%

He is solving Question FLOW007

(13 Jun, 17:57) abhineet145★

while (temp>=1 && temp<=100000)

Make it while(temp>=1)

There is a problem with test cases. The external setter didnt has made cases where $N>100000$. Will notify it to @admin for fixing.

link

answered 13 Jun, 17:57

vijju123's gravatar image

5★vijju123 ♦
13.6k11036
accept rate: 19%

accepted after while(temp>=1).

Thanks

(14 Jun, 09:52) mohitkhetan0★

Well, you are not wrong. Your code is 100% correct. There is a problem with some of the test cases. They are not according to the constraint. In those cases N>100000. That's why it is evaluated as WA.

link

answered 13 Jun, 18:01

abhineet14's gravatar image

5★abhineet14
3918
accept rate: 8%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×26

question asked: 13 Jun, 17:11

question was seen: 64 times

last updated: 14 Jun, 09:52