10706 - Number Sequence

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

Moderator: Board moderators

htl
Experienced poster
Posts: 185
Joined: Fri Jun 28, 2002 12:05 pm
Location: Taipei, Taiwan

10706 - Number Sequence

Post by htl » Mon Aug 30, 2004 5:19 pm

It seems to be easy problem. I got so many wa... Could someone give some test cases?

Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Post by Observer » Mon Aug 30, 2004 5:23 pm

Hi, I can't think of any tricky cases, and random cases aren't very useful here...

Anyway, for i = 2147483647, the output = 2. :)
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org

htl
Experienced poster
Posts: 185
Joined: Fri Jun 28, 2002 12:05 pm
Location: Taipei, Taiwan

Post by htl » Mon Aug 30, 2004 5:27 pm

My output of 2147483647 is right.

How about these?

in:
14
23423
65753
2345
45645756
546454
6786797
131231
78934124
68904565
123487907
5655
778888
101011
546

out:
3
1
5
0
2
5
9
9
2
1
1
5
5
2

Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Post by Observer » Mon Aug 30, 2004 5:42 pm

I get this:
3
1
5
5
2
5
9
7
5
7
1
5
5
2
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org

htl
Experienced poster
Posts: 185
Joined: Fri Jun 28, 2002 12:05 pm
Location: Taipei, Taiwan

Post by htl » Mon Aug 30, 2004 5:56 pm

Find out a silly bug and go ac... Thank you for your reply :D

Minilek
Learning poster
Posts: 90
Joined: Tue Jul 27, 2004 9:34 am
Location: Cambridge, MA
Contact:

Post by Minilek » Tue Aug 31, 2004 11:24 pm

[c]
AC
made stupid mistake
[/c]

Faizur
New poster
Posts: 39
Joined: Fri Jun 06, 2003 3:04 pm

WA

Post by Faizur » Tue Sep 07, 2004 6:03 am

Hi,
I think the problem is quite an easy one. My problem give correct answers for all the above test cases. But i m still getting WA :x with this problem.
[c]
#include<stdio.h>
#include<math.h>
void print(double n)
{
double m;
char str[100];
int i;
n++;
if(n<=10)
printf("%.0f",(n-1));
else if(n<=190)
{
n -= 10;
m = ceil(n/2) - 1;
i = n - m*2 - 1;
m += 10;
sprintf(str,"%.0lf",m);
putchar(str);
}
else if(n<=2890)
{
n -= 190;
m = ceil(n/3) - 1;
i = n - m*3 - 1;
m += 100;
sprintf(str,"%.0lf",m);
putchar(str);
}
else if(n<=38890)
{
n -= 2890;
m = ceil(n/4) - 1;
i = n - m*4 - 1;
m += 1000;
sprintf(str,"%.0lf",m);
putchar(str);
}
else if(n<=488890)
{
n -= 38890;
m = ceil(n/5) - 1;
i = n - m*5 - 1;
m += 10000;
sprintf(str,"%.0lf",m);
putchar(str);
}
else if(n<=5888890)
{
n -= 488890;
m = ceil(n/6) - 1;
i = n - m*6 - 1;
m += 100000;
sprintf(str,"%.0lf",m);
putchar(str);
}
else if(n<=68888890)
{
n -= 5888890;
m = ceil(n/7) - 1;
i = n - m*7 - 1;
m += 1000000;
sprintf(str,"%.0lf",m);
putchar(str);
}
else if(n<=788888890)
{
n -= 68888890;
m = ceil(n/8) - 1;
i = n - m*8 - 1;
m += 10000000;
sprintf(str,"%.0lf",m);
putchar(str);
}
putchar('\n');

}
int main()
{
double a,n,t;
long test,i;
double range[10],d=90,digit[10],p,x;
n=0,i=1,t=9;
range[0]=45;
digit[0]=9;
while(i<8)
{
n=range[i-1]+t*d+(((i+1)*d*(d+1))/2.0);
t+=d*(i+1);
digit=t;
range=n;
i++;
d*=10;
}
scanf("%ld",&test);
while(test--)
{
scanf("%lf",&a);
for(i=0;;i++)
if(range>a)
break;
a=a-range[i-1];
d=i+1;
if(!i)
x=0;
else
x=digit[i-1];
p=(2.0*x+d);
p=((sqrt(p*p+8.0*d*a)-p)/(2.0*d));
p=ceil(p)-1;
a-=d*(p*(p+1.0)/2.0)+p*x;
print(a);
}
}
[/c]
Can someone give me some test cases or find out the reson for getting WA.
Thanx in advance
___________________
Faizur
Cuet Old Sailor

Md. Azam Khan
New poster
Posts: 8
Joined: Tue Jun 15, 2004 7:16 pm
Location: Chittagong, Bangladesh
Contact:

Post by Md. Azam Khan » Mon Sep 13, 2004 9:06 pm

Hi Old Sailor (Faizur)!
Your program gives correct answer for all the test cases greater than 45, doesn't it? Seem to me, if u solve "the bug" u will get it accepted. So i m giving u 45 test cases: 1 to 45.

Best regards,
Md. Azam Khan, NewSailor!!!

I born to code :evil:

Morning
Experienced poster
Posts: 134
Joined: Fri Aug 01, 2003 2:18 pm
Location: Shanghai China

10706 Why WA???

Post by Morning » Sat Sep 25, 2004 6:48 pm

[cpp]
#include <iostream.h>
#include <math.h>

long long sum(long long n)
{
return n * (n + 1) / 2;
}
int sol(long long x)
{
int i;
for (i = 1;sum(i) < x;i++)
{

}
return x - sum(i - 1);
}

int main()
{
int n;
long long x;
cin >> n;
while (n--)
{
cin >> x;
cout << sol(x);
}
return 0;
}
[/cpp]
"Learning without thought is useless;thought without learning is dangerous."
"Hold what you really know and tell what you do not know -this will lead to knowledge."-Confucius

wiktor
New poster
Posts: 5
Joined: Wed Sep 22, 2004 6:13 pm

Post by wiktor » Sun Sep 26, 2004 12:16 am

Two (at least) errors:
* no new line "\n" after each test case
* you print a decimal number instead of digt

chceck this

1
55

your output : 10
my output : 1

Morning
Experienced poster
Posts: 134
Joined: Fri Aug 01, 2003 2:18 pm
Location: Shanghai China

Post by Morning » Sun Sep 26, 2004 12:08 pm

yeah,i got what u mean,thanx so much
"Learning without thought is useless;thought without learning is dangerous."
"Hold what you really know and tell what you do not know -this will lead to knowledge."-Confucius

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Fri Jul 15, 2005 6:17 am

What is the output for the following input set?

Input:

Code: Select all

10
1345262
78812653
526374512
2100999900
67281
84
764129000
128656729
89879872
554267711
Thanks in advance.
Ami ekhono shopno dekhi...
HomePage

User avatar
Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post by Krzysztof Duleba » Fri Jul 15, 2005 3:10 pm

The output is

Code: Select all

7
4
3
7
3
2
1
3
6
1

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Wed Jul 20, 2005 7:52 am

Thanks for the reply Krzysztof Duleba, I got it Accepted. :D

Thanks again...
Ami ekhono shopno dekhi...
HomePage

tRipper
New poster
Posts: 22
Joined: Sun Mar 13, 2005 5:04 pm
Location: out there

Post by tRipper » Mon Nov 07, 2005 7:59 pm

What's the output for the following input?

Code: Select all

3
2147483647
9045
123456789
My program (WA) gives

Code: Select all

2
9
3
If I am out of my mind, it's all right with me.

Post Reply

Return to “Volume 107 (10700-10799)”