Page **7** of **7**

### Re: 424 - Integer Inquiry

Posted: **Tue Oct 21, 2014 1:55 pm**

by **lighted**

Use code tags.

Input

Acc Output

Don't forget to remove your code after getting accepted.

### Re: 424 - Integer Inquiry

Posted: **Wed Feb 25, 2015 7:57 am**

by **mgavin2**

The udebug code for this problem has to be wrong.

The java AC solution reads big integers until the number equals 0 and keeps the running sum.

### Re: 424 - Integer Inquiry

Posted: **Thu Feb 26, 2015 2:09 am**

by **brianfry713**

If you think that this is wrong:

http://www.udebug.com/UVa/424
Then please provide input that it is failing.

For your code, change line 114 to:

int dataReadFlag = TRUE;

### Re: 424 - Integer Inquiry

Posted: **Thu Feb 26, 2015 4:48 am**

by **mgavin2**

input:

output

The java solution would throw a runtime error..

also:

input

gives

when the java solution should give -3

input:

gives nothing, when the java AC solution would report 0.

I know the problem statement says:

The input will consist of at most 100 lines of text, each of which contains a single VeryLongInteger. Each VeryLongInteger will be 100 or fewer characters in length, and will only contain digits (no VeryLongInteger will be negative).

but we aren't accustomed to problem statements always being right. It could be misleading in saying that you should discard input that is negative or contains characters other than digits. For example, problem 1585 where it says "There is no spaces between `O' and `X'. " , when there could be spaces elsewhere.

### Re: 424 - Integer Inquiry

Posted: **Thu Feb 26, 2015 9:15 pm**

by **brianfry713**

The judge's input for this problem only contains digits and has no leading zeros.

It doesn't matter what you or the uDebug solution prints for invalid input.

### Getting WA

Posted: **Mon Jun 22, 2015 12:18 pm**

by **nhimran**

I am getting wrong answer with my code. can anyone help me please ?

Code: Select all

```
#include<stdio.h>
#include<string.h>
#define siz 120
int main()
{
char num[102],sum[siz],tmp;
int i,j,ln,res,carry;
memset(sum,0,siz);
while(1){
scanf("%s",num);
if(strcmp(num,"0")==0){
break;
}
ln=strlen(num);
for(i=0;i<ln/2;i++){
tmp = num[i];
num[i]=num[ln-1-i];
num[ln-1-i]=tmp;
}
carry = 0;
for(i=0;i<siz;i++){
if(i<ln){
j=num[i]-'0';
}
else{
j=0;
}
sum[i]= carry+sum[i]+j;
if(sum[i]>9){
sum[i]=sum[i]%10;
carry = 1;
}
else{
carry=0;
}
}
}
for(i=siz-1;i>=0;i--){
if(sum[i]!=0)break;
}
for(;i>=0;i--){
printf("%d",sum[i]);
}
return 0;
}
```

### Re: 424 - Integer Inquiry

Posted: **Tue Nov 10, 2015 6:59 pm**

by **xYinXiao**

Hello there, I actually have a problem with my code. The problem here is that I don't know where the problem is. The output should be correct, but as I try to submit my code, it says WA. Would someone be so kind to find the issue in my code?

Code: Select all

```
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
int main() {
vector<int> sum(1000, 0);
char str[101];
int i;
while(scanf("%s", str) && str[0] != '0') {
i = 0;
int n = strlen(str);
while(i < n) {
sum[i] += (str[n - 1 - i] - '0');
i++;
}
}
int last = 0;
for(i = 0;i < 1000;i++) {
sum[i + 1] += (sum[i] / 10);
sum[i] %= 10;
if (sum[i] != 0)
last = i;
}
for(i = last;i >= 0;i--) {
printf("%d", sum[i]);
}
return 0;
}
```

Thanks~