Page 1 of 3

10706 - Number Sequence

Posted: Mon Aug 30, 2004 5:19 pm
It seems to be easy problem. I got so many wa... Could someone give some test cases?

Posted: 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.

Posted: Mon Aug 30, 2004 5:27 pm
My output of 2147483647 is right.

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

Posted: Mon Aug 30, 2004 5:42 pm
I get this:
3
1
5
5
2
5
9
7
5
7
1
5
5
2

Posted: Mon Aug 30, 2004 5:56 pm
Find out a silly bug and go ac... Thank you for your reply

Posted: Tue Aug 31, 2004 11:24 pm
[c]
AC
[/c]

WA

Posted: 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 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.
___________________
Faizur
Cuet Old Sailor

Posted: 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

10706 Why WA???

Posted: 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]

Posted: 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

my output : 1

Posted: Sun Sep 26, 2004 12:08 pm
yeah,i got what u mean,thanx so much

Posted: 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``````

Posted: Fri Jul 15, 2005 3:10 pm
The output is

Code: Select all

``````7
4
3
7
3
2
1
3
6
1``````

Posted: Wed Jul 20, 2005 7:52 am
Thanks for the reply Krzysztof Duleba, I got it Accepted.

Thanks again...

Posted: 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
``````