424 - Integer Inquiry
Moderator: Board moderators
-
- New poster
- Posts: 38
- Joined: Wed Dec 05, 2012 11:29 pm
Re: 424 - Integer Inquiry RE
Code removed after getting accepted
Last edited by mobarak.islam on Tue Jan 22, 2013 3:59 pm, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 424 - Integer Inquiry RE
For inputthe output should be:"200\n", you're printing "2\n0\n0\n"
Code: Select all
100
100
0
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 38
- Joined: Wed Dec 05, 2012 11:29 pm
Re: 424 - Integer Inquiry RE
@ brianfry713 , I got accepted. Thanks ![:)](./images/smilies/icon_smile.gif)
![:)](./images/smilies/icon_smile.gif)
Re: 424, Compile ERROR??
CE ! why?
Code: Select all
#include<stdio.h>
int main()
{
int i=1,j,k,d,l,l1,l2,sum,carry,max;
char text[101][101];
while(gets(text[i]),text[i][0]!='0')
{
sum=carry=0;
if(i>=2)
{
l1=strlen(text[i-1])-1;
l2=strlen(text[i])-1;
if(l2>l1)
{
//l1=strlen(text[i-1])-1;
//l2=strlen(text[i])-1;
j=max=l2;
//j=l1;
d=l2-l1;
//printf("-%s\n",text[i-1]);
for(k=1; k<=d; k++)
{
l1=strlen(text[i-1])-1;
for(l=l1; l>=0; l--)
{
//printf("%c %c\n",text[i-1][l+1],text[i-1][l]);
text[i-1][l+1]=text[i-1][l];
}
}
for(k=0; k<d; k++)
text[i-1][k]='0';
//printf("%d\n",d);
//printf("-%s\n",text[i-1]);
}
else if(l1>l2)
{
//l1=strlen(text[i-1])-1;
//l2=strlen(text[i])-1;
j=max=l1;
//j=l2;
d=l1-l2;
for(k=1; k<=d; k++)
{
l2=strlen(text[i])-1;
for(l=l2; l>=0; l--)
text[i][l+1]=text[i][l];
}
for(k=0; k<d; k++)
text[i][k]='0';
//printf("+%s\n",text[i]);
}
else
{
l1=strlen(text[i-1]);
l2=strlen(text[i]);
max=l1;
j=l1-1;
}
while(j>=0)
{
//printf("%c %c\n",text[i-1][j],text[i][j]);
sum=(text[i-1][j]-'0')+(text[i][j]-'0')+carry;//Adding two numbers
if(sum>9)
{
text[i][j]=(sum%10)+'0';
carry=1;
}
else
{
text[i][j]=sum+'0';
carry=0;
}
//printf("%c",text[i][j]);
j--;
}
if(carry==1)
{
for(j=max; j>=0; j--)
text[i][j+1]=text[i][j];
text[i][0]='1';
}
//printf("*%s\n",text[i]);
}
i++;
}
printf("%s\n",text[i-1]);
return 0;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 424, Compile ERROR??
You can click My Submissions to see the reason for your CE.
#include <string.h>
#include <string.h>
Check input and AC output for thousands of problems on uDebug!
424 - Integer Inquiry. Why RTE???
Last edited by me33 on Sun Mar 09, 2014 7:42 pm, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 424 - Integer Inquiry. Why RTE???
Don't use a package.
http://uva.onlinejudge.org/index.php?op ... &Itemid=30
Post in the appropriate forum, volume IV instead of General.
http://uva.onlinejudge.org/index.php?op ... &Itemid=30
Post in the appropriate forum, volume IV instead of General.
Check input and AC output for thousands of problems on uDebug!
Re: 424 - Integer Inquiry. Why RTE???
Thanks brianfry713...
Got AC
![:D](./images/smilies/icon_biggrin.gif)
Got AC
![:D](./images/smilies/icon_biggrin.gif)
![:)](./images/smilies/icon_smile.gif)
![:D](./images/smilies/icon_biggrin.gif)
-
- New poster
- Posts: 49
- Joined: Mon Jun 16, 2014 7:40 pm
UVA problem no. 424 WA
Code removed
Last edited by richatibrewal on Sun Jul 20, 2014 6:10 pm, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: UVA problem no. 424 WA
Input:AC output:
Code: Select all
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
0
Code: Select all
999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999900
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 49
- Joined: Mon Jun 16, 2014 7:40 pm
Re: UVA problem no. 424 WA
I am getting the required output
Re: UVA problem no. 424 WA
You must increase parameters
It must be
For all problems make limit of arrays bigger than problems says. ![:wink:](./images/smilies/icon_wink.gif)
Code: Select all
char a[100],b[1];
int i=0,k,sum=0,j[100][100]={0},m,f[100]={0},n=0,l,o,p=0,d,max=INT_MIN;
Code: Select all
char a[101],b[2];
int i=0,k,sum=0,j[101][101]={0},m,f[101]={0},n=0,l,o,p=0,d,max=INT_MIN;
![:wink:](./images/smilies/icon_wink.gif)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
-
- New poster
- Posts: 49
- Joined: Mon Jun 16, 2014 7:40 pm
Re: UVA problem no. 424 WA
Thank u so much. My code is now accepted ![:)](./images/smilies/icon_smile.gif)
![:D](./images/smilies/icon_biggrin.gif)
![:)](./images/smilies/icon_smile.gif)
![:D](./images/smilies/icon_biggrin.gif)
Re: UVA problem no. 424 WA
It will be good if you remove your code after getting accepted. ![8)](./images/smilies/icon_cool.gif)
![8)](./images/smilies/icon_cool.gif)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
-
- New poster
- Posts: 6
- Joined: Tue Oct 21, 2014 12:51 pm
Re: 424 - Integer Inquiry
Why i am getting WA each time? i have tried all test cases available...but still it's WA!!! can anyone help plz???????????????
Code: Select all
#include <iostream>
using namespace std;
int main()
{
string s;
char a[110];
int i,j,c,b,n=0;
for(i=0;i<110;i++)
a[i]='0';
a[i]=NULL;
while(1)
{
getline(cin,s);
if(s=="0")
break;
if(n<s.size()) n=s.size();
c=0;
for(i=s.size()-1,j=0;i>=0;i--,j++)
{
b=(s[i]-'0')+(a[j]-'0')+c;
if(b>9)
{
c=b/10;
a[j]=(b%10)+'0';
}
else
{
c=0;
a[j]=b+'0';
}
}
if(c>0)
{
while(c!=0)
{
b=(a[j]-'0')+c;
a[j]=(b%10)+'0';
c=(b+c)/10;
j++;
}
}
}
if(a[n]!='0') cout << a[n];
for(i=n-1;i>=0;i--)
cout << a[i];
cout << endl;
return 0;
}
Last edited by brianfry713 on Tue Oct 21, 2014 7:35 pm, edited 1 time in total.
Reason: Added code blocks
Reason: Added code blocks