..../\....> > = [0, 2, 3, 9, 2, 2, ... ] in continuous
....||....
how it comes
WHO WILL HELP ME?
Moderator: Board moderators
Code: Select all
7
8
15
12
20
31
28748
24559
4813
325147
325148
11036
37937
6432163
146964308
146964307
Code: Select all
1
2
3
4
5
111
222
333
444
555
66666
77777
88888
99999
111111
111222
333444
555666
999900
123456
654321
100000
200000
300000
400000
500000
Code: Select all
7
8
15
12
9
143
629
314
1600
1597
224296
26399
123446
254370
194220
94220
2250226
225093
5766432
63293
78171
70777
325148
3606692
325149
325146
Code: Select all
7
8
15
12
9
143
629
314
1600
1597
224296
26399
123446
254370
194220
94220
2250226
225093
5766432
63293
78171
70777
325148
3606692
325149
325146
Code: Select all
works now.
I had calculated the 2^146964308 with big number.eyhk wrote:For sedafcho's input, I got a different output, the last two.
I'm not able to find 2^31 though.
Code: Select all
7 8 15 12 20 31 28748 24559 4813 325147 325148 11036 37937 6432163 146964308 146964307
Code: Select all
7
8
15
12
9
143
629
314
1600
1597
224296
26399
123446
254370
194220
94220
2250226
225093
5766432
63293
78171
70777
325148
3606692
325149
325146
real 0m1.819s
user 0m1.650s
sys 0m0.038s
SiburNY wrote:Thanks for trying to help me. I use C. I have Athlon XP 2200 768Mb computer. This time I tweaked my code a little. It took 11-12 seconds to finish the following numbers:
Input:Output:Code: Select all
1 2 3 4 5 111 222 333 444 555 66666 77777 88888 99999 111111 111222 333444 555666 999900 123456 654321 100000 200000 300000 400000 500000
Thank you.Code: Select all
7 8 15 12 9 143 629 314 1600 1597 224296 26399 123446 254370 194220 94220 2250226 225093 5766432 63293 78171 70777 325148 3606692 325149 325146
Code: Select all
#include<iostream>
#include<string>
#include<stdio.h>
#include<cmath>
using namespace std;
string mult(string,int);
bool check(string,char*);
int main()
{
float x,k;
int div=1;
string str = "1";
int n=1;
char ch[10];
while(cin>>x)
{
div = 1;
str = "1";
n=1;
sprintf(ch,"%d",(int)x);
while(!check(str,ch))
{
k = log10(x)/log10((double)2) + (strlen(ch)+n)*1/log10((double)2);
for(int i=div;i<=ceil(k);i++)
{
str=mult(str,2);
}
div = ceil(k)+1;
n++;
}
cout<<div-1<<endl;
}
return 0;
}
string mult(string s,int n)
{
int carry=0;
int k;
string result = "";
for(int i=s.length()-1;i>=0;i--)
{
k=(s[i]-'0')*n;
result.insert(0,(char)((k%10)+48+carry));
if(k>=10)
{
carry = k/10;
}
else
carry = 0;
}
if(carry!=0)
{
result.insert(0,(char)(carry+48));
}
return result;
}
bool check(string s1,char* s2)
{
int n;
n = s1.length();
if(s1.length()%2!=0)
n++;
if(n/2<=strlen(s2))
return false;
for(int i=0;i<strlen(s2);i++)
{
if(s1[i] != s2[i])
return false;
}
return true;
}