10023 - Square Root

All about problems in Volume C. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Postby .. » Sat Dec 11, 2004 9:32 pm

windows2k wrote:Hello, I have passed the problem before rejudge.
But I got TLE all the time.
Could someone offer an proper algorithm to solve the problem?
Thx :D


http://online-judge.uva.es/board/viewto ... ight=10606
My signature:
  • Please make discussion about the algorithm BRFORE posting source code.
    We can learn much more in discussion than reading source code.
  • I HATE testing account.
  • Don't send me source code for debug.
..
A great helper
 
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

10023

Postby eshika » Wed Dec 15, 2004 6:59 am

Can anybody tell me, why WA?
[c]
#include<stdio.h>
#include<math.h>

void main()
{
int n,i;
long double x,y;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%Lf",&y);
x=sqrtl(y);
printf("%.0Lf\n\n",x);
}
}

[/c]
eshika
New poster
 
Posts: 11
Joined: Sat Oct 02, 2004 12:02 pm
Location: Bangladesh

Postby shamim » Wed Dec 15, 2004 8:18 am

look at the size of input, basic data types can't handle it.
User avatar
shamim
A great helper
 
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Dhaka

Postby eshika » Wed Dec 15, 2004 10:11 am

Would you explain in more details?
Should I use string operations? I have read few threads in this forum regarding 727 after I got WA. Many of them get accepted using sqrtl() with long double. As I expected sqrtl() surprisingly solves the problem. Then what is wrong with my code?
eshika
New poster
 
Posts: 11
Joined: Sat Oct 02, 2004 12:02 pm
Location: Bangladesh

Postby Niaz » Sat Dec 18, 2004 5:08 pm

After re-judging, this function has become a 'baby' one. Now the real challenge is waiting for every one. :)
Please join The ACM Solver Group at Yahoo
http://groups.yahoo.com/group/acm_solver/
Niaz
Learning poster
 
Posts: 77
Joined: Fri Dec 17, 2004 11:06 am
Location: East West University, Dhaka, Bangladesh

10023 Why WA ????

Postby jan_holmes » Sun Apr 24, 2005 8:13 am

Hi,I have a problem in 10023,I always got WA,anyone could help ???

#include <stdio.h>
#include<math.h>

void main()
{
int a,i;
long double y;
scanf("%d",&a);
for(i=0;i<a;i++)
{
scanf("%Lf",&y);
printf("%.0Lf\n",sqrtl(y));
printf("\n");
}
}
jan_holmes
Experienced poster
 
Posts: 136
Joined: Fri Apr 15, 2005 3:47 pm
Location: Singapore

10023 - Square Root

Postby Sanny » Sun Apr 24, 2005 7:44 pm

The number can be 1000 digits long. So you just can't do it so simple. You could have done it if the number was at most 15-16 digit I guess. You need to use bigint to solve this problem.

Regards
Sanny
Sanny
Learning poster
 
Posts: 78
Joined: Sat Feb 14, 2004 3:59 pm
Location: BUET

10023

Postby asif_rahman0 » Tue May 31, 2005 6:52 pm

Hey that's my code.I've got WR.But can't understand why?Plz help me to understand.

#include<stdio.h>
#include<math.h>
void main()
{
long double y;
int x;
scanf("%d",&x);
while(x--)
{
printf("\n");
scanf("%Lf",&y);
printf("%.0Lf\n",sqrtl(y));
}
}
asif_rahman0
Experienced poster
 
Posts: 209
Joined: Sun Jan 16, 2005 6:22 pm

Postby chunyi81 » Wed Jun 01, 2005 6:01 am

Read the problem description: Biggest input is 10^1000 (that is 1000 digits)

You have to use big integer.
chunyi81
A great helper
 
Posts: 293
Joined: Sat Jun 21, 2003 4:19 am
Location: Singapore

Postby Rocky » Wed Jun 01, 2005 9:01 am

Yes You Need BigInteger And You Need To Solve It With Manullay squre root.

GOOD LUCK
Rocky
User avatar
Rocky
Experienced poster
 
Posts: 124
Joined: Thu Oct 14, 2004 9:05 am

10023

Postby A1 » Wed Jul 20, 2005 2:50 pm

I tried a lot, but still i m in TLE! :evil:
I send only a input taking code and i run upto 0.010s! so i think input file is very big.
My best timing is 11.9 s for 100 maximum lenth input in my 600MHz pc, and I think i cann't do more then this :cry:

I want to request the judge to reduce it's input so that more people can solve it in different method, (not only in the way that the problem setter have :x )

if any one wants to help me plz send me a PM
User avatar
A1
Experienced poster
 
Posts: 173
Joined: Wed Jan 28, 2004 3:34 pm
Location: Bangladesh

Postby daveon » Sat Aug 06, 2005 11:08 pm

Perhaps somewhere down along the road, you will come up with a better solution.

Problems that take you the most time to solve are the problems that you'll likely admire the most.

And how do you know if there is only one way to solve this?
daveon
Experienced poster
 
Posts: 229
Joined: Tue Aug 31, 2004 2:41 am
Location: TORONTO, CANADA

Postby A1 » Thu Aug 25, 2005 7:16 am

Have you solve this problem?
User avatar
A1
Experienced poster
 
Posts: 173
Joined: Wed Jan 28, 2004 3:34 pm
Location: Bangladesh

10023

Postby Salman » Mon Aug 29, 2005 8:20 am

Please someone check Why WA?

Code: Select all

/*
Name: Squre root
Number: 10023
Type :  math
Process : ON
Author :Salman Zaman
Email : zamansalman@gmail.com
Date : 24/08/05 23:31





*/



#include<stdio.h>
#include<math.h>

//#include<conio.h>



int main(){

       long double y;
       long n;

   //    freopen("10023.txt","r",stdin);
       
        scanf("%ld",&n);
        for(;n;n--){
            scanf("%lf",&y);
            printf("%.0lf\n\n",sqrtl(y));
      } 
     
 //  getch();
   return 0;
}


Salman
New poster
 
Posts: 25
Joined: Thu Jun 26, 2003 9:45 am

Postby daveon » Mon Aug 29, 2005 11:33 am

As of today, this problem still remains unsolved from my point of view.
daveon
Experienced poster
 
Posts: 229
Joined: Tue Aug 31, 2004 2:41 am
Location: TORONTO, CANADA

PreviousNext

Return to Volume C

Who is online

Users browsing this forum: No registered users and 1 guest