Page 5 of 7

### Re: 424 - Integer Inquiry RE

Posted: Thu Sep 23, 2010 9:00 pm
The memory limits are enough why use so small limits on arrays. Use 1000.

### Re: 424 - Integer Inquiry RE

Posted: Tue Nov 16, 2010 7:42 pm
plz help me... I hv used much bigger array.... It's still in no use....

Code: Select all

``````#include<stdio.h>
#include<string.h>
void str_rev(char str[]);
int main()
{

char str[1001][1001],str3[1002];

int i,j,k,m,x=0,carry=0,max=0;

for(i=0;i<101;i++)
{
gets(str[i]);

if(str[i][0]=='0'&&str[i][1]=='\0')
break;

if(strlen(str[i])>=max)
max=strlen(str[i]);

}

j=i;
for(i=0;i<j;i++)
{
str_rev(str[i]);
for(k=strlen(str[i]);k<max;k++)
{
str[i][k]='0';
}
str[i][k]='\0';
str_rev(str[i]);
}

for(k=max-1,m=0;k>=0,m<max;k--,m++)
{
x=0;
for(i=0;i<j;i++)
{

x+=(str[i][k]-'0')+carry;

carry=0;
}
if(x>9)
{
carry=x/10;
str3[m]=x%10+'0';
}
else
str3[m]=x+'0';
}

str3[max]=carry+'0';

if((str3[max]-'0')==0)
str3[max]='\0';
else
str3[max+1]='\0';

str_rev(str3);
puts(str3);

return 0;
}

void str_rev(char str[])
{
char a;
int i,j,n;

n=strlen(str);

for(i=0,j=n-1;i<n/2&&j>=0;i++,j--)
{
a=str[i];
str[i]=str[j];
str[j]=a;
}

str[n]='\0';

}``````

### 424 - Integer Inquiry RE

Posted: Thu Dec 16, 2010 6:38 pm
I dont know why im getting RE?? Plz help me to find out.
I have code in Java using BigInteger.
Here is my Code

Code: Select all

``````import java.util.*;
import java.math.*;
import javax.swing.*;

public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner sc=new Scanner(System.in);

BigInteger a,sum;

sum= BigInteger.ZERO;

while(true){
a= sc.nextBigInteger();
if(a.intValue()==0)break;
}

System.out.print(sum) ;
}
}
``````

### Re: 424 - Integer Inquiry RE

Posted: Fri Jun 17, 2011 8:15 am
what will be the output for

0000
0000
0000
0
plz...

### Re: 424 - Integer Inquiry RE

Posted: Fri Jun 17, 2011 8:56 am
Got AC

Code: Select all

``````AC
``````

### Re: 424 - Integer Inquiry RE

Posted: Fri Jun 17, 2011 8:56 am
AC

Code: Select all

``````
``````

### 424 - Integer Inquiry: WA!!!!

Posted: Fri Aug 19, 2011 11:30 am
plz help me....
here is my code-

Code: Select all

``````#include<stdio.h>

int main()
{
char inp[101],out[110];
int i,j,c,tempc;
for(i=0;i<110;i++)
out[i]='0';
while(scanf("%s",inp)==1)
{
for(i=0;inp[i]!='\0';i++);
for(c=0,j=109,i--;i>=0;i--,j--)
{
tempc=c;
c=(c+out[j]+inp[i]-96)/10;
out[j]=(tempc+out[j]+inp[i]-96)%10+48;
}
if(c)
out[j]=c+out[j];
if(inp[0]=='0'&&inp[1]=='\0')
{
for(i=0;out[i]=='0';i++);
j=i;
for(;i<110;i++)
printf("%c",out[i]);
printf("\n");
for(;j<110;j++)
out[j]='0';
}
}
return 0;
}
``````

### Re: 424, Compile ERROR??

Posted: Mon Feb 20, 2012 11:41 am
Just you Include the code given below in your code..

Code: Select all

``````#include<cstdio>
``````

### Re: 424 - Integer Inquiry RE

Posted: Mon Aug 06, 2012 3:48 pm
I am getting WA again and again .. form my side , I think I've covered all the test cases .
The algorithm is also straightforward .... scan - reverse and then add , this too in the reverse fashion and output the results in the reversed fasion as well .Can anyone tell me what am I missing or doing wrongly ?

Code: Select all

``````code removed after AC
``````

### Re: 424 - Integer Inquiry RE

Posted: Tue Aug 07, 2012 1:29 am
100
1
0

### Re: 424 - Integer Inquiry RE

Posted: Tue Aug 07, 2012 10:42 am
brianfry713 wrote:100
1
0
Thanks dude , I got the point . It was my first ever forum post , and it was really helpful . ACed

### Re: 424 - Integer Inquiry RE

Posted: Thu Jan 10, 2013 11:46 am
code removed

### Re: 424 - Integer Inquiry RE

Posted: Thu Jan 10, 2013 11:00 pm
Try input:

Code: Select all

``````9
9
0``````

### Re: 424 - Integer Inquiry RE

Posted: Tue Jan 15, 2013 8:21 am
code removed

### Re: 424 - Integer Inquiry RE

Posted: Tue Jan 15, 2013 9:04 pm
Print a newline at the end of the output.