Page 4 of 5
Re: 10929 - You can say 11
Posted: Sun Jul 07, 2013 7:40 pm
by Faithkeeper_Rangwan
Code: Select all
import java.util.*;
import java.math.*;
class Main
{
public static void main(String[] args)
{
BigInteger a,b;
Scanner sc = new Scanner(System.in);
a = sc.nextBigInteger();
while(!a.equals(BigInteger.ZERO))
{
b =a.mod(BigInteger.valueOf(11));
if(b.equals(BigInteger.ZERO)) System.out.println(a+" is a multiple of 11.");
else System.out.println(a+" is not a multiple of 11.");
a = sc.nextBigInteger();
}
}
}
Also got WA with this one, don't know how to fix this

Re: 10929 - You can say 11
Posted: Mon Jul 08, 2013 11:52 pm
by brianfry713
Re: 10929 - You can say 11
Posted: Thu Jul 11, 2013 4:40 pm
by Faithkeeper_Rangwan
brianfry713 wrote:input:
output should be
AC'd
Thanks.
UVA 10929
Posted: Sun Oct 20, 2013 7:28 pm
by woaraka92
#include<stdio.h>
#include<string.h>
int main(){
char a[1002];
int i,sum;
while(1){
scanf("%s",a);
if(strcmp(a,"0")==0)
break;
sum=0;
for(i=0;a!='\0';i++){
sum=sum*10+a-48;
if(sum<11){
i++;
sum=sum*10+a-48;
}
if(sum>10)
sum=sum%11;
}
if(sum==0)
printf("%s is a multiple of 11.\n",a);
else
printf("%s is not a multiple of 11.\n",a);
}
return 0;
}
Re: UVA 10929
Posted: Sun Oct 20, 2013 7:33 pm
by woaraka92
whats the problem in this code?
Re: UVA 10929
Posted: Mon Oct 21, 2013 9:25 pm
by brianfry713
110 is a multiple of 11.
Re: UVA 10929
Posted: Wed Oct 23, 2013 9:18 pm
by woaraka92
Thanks brianfry713..
Re: 10929 - You can say 11
Posted: Thu Mar 13, 2014 10:00 pm
by jddantes
What's wrong with mine?
Also by positive number do they mean positive integers?
Code: Select all
#include <stdio.h>
#include <string.h>
int main()
{
char number[1005];
while(fgets(number, 1005, stdin)!=NULL)
{
number[strlen(number)-1] = 0;
if(number[0] == '0' && number[1] == 0)
{
return 0;
}
int sum = 0;
int i = 0;
for(i=0; number[i];i++)
{
if(i%2 == 0)
{
sum+=number[i] - '0';
}
else
{
sum-=number[i] - '0';
}
//printf("%d %d\n",sum, number[i] - '0');
}
if (sum % 11 == 0)
{
printf("%s is a multiple of 11.\n",number);
}
else
{
printf("%s is not a multiple of 11.\n",number);
}
}
return 0;
}
Re: 10929 - You can say 11
Posted: Fri Mar 14, 2014 9:02 pm
by brianfry713
That is AC code.
Yes they mean positive integers.
Re: 10929 - You can say 11
Posted: Sun Mar 16, 2014 1:22 pm
by jddantes
Why is mine WA?
Code: Select all
#include <stdio.h>
#include <string.h>
int main()
{
char number[1005];
while(fgets(number, 1005, stdin)!=NULL)
{
number[strlen(number)-1] = 0;
if(number[0] == '0' && number[1] == 0)
{
return 0;
}
int sum = 0;
int i = 0;
for(i=0; number[i];i++)
{
if(i%2 == 0)
{
sum+=number[i] - '0';
}
else
{
sum-=number[i] - '0';
}
//printf("%d %d\n",sum, number[i] - '0');
}
if (sum % 11 == 0)
{
printf("%s is a multiple of 11.\n",number);
}
else
{
printf("%s is not a multiple of 11.\n",number);
}
}
return 0;
}
Re: 10929 - You can say 11
Posted: Mon Mar 17, 2014 9:55 pm
by brianfry713
That is AC code.
Re: 10929 - You can say 11
Posted: Mon Mar 24, 2014 7:38 am
by uDebug
So, for this problem, it turns out that there are
two outputs that are both accepted.
For, the following input
Code: Select all
112233
00000000030800
2937
323455693
5038297
00000112234
00112
0
AC Output #1:
Code: Select all
112233 is a multiple of 11.
00000000030800 is a multiple of 11.
2937 is a multiple of 11.
323455693 is a multiple of 11.
5038297 is a multiple of 11.
00000112234 is not a multiple of 11.
00112 is not a multiple of 11.
AC Output #2:
Code: Select all
112233 is a multiple of 11.
00000000030800 is a multiple of 11.
2937 is a multiple of 11.
323455693 is not a multiple of 11.
5038297 is a multiple of 11.
00000112234 is not a multiple of 11.
00112 is not a multiple of 11.
Re: 10929 - You can say 11
Posted: Tue Mar 25, 2014 12:15 am
by brianfry713
There probably aren't spaces in the judge's input.
Re: 10929 - You can say 11
Posted: Tue Mar 25, 2014 8:14 am
by uDebug
brianfry713 wrote:There probably aren't spaces in the judge's input.
That makes sense. Thanks.
Re: 10929 - You can say 11
Posted: Sun Mar 30, 2014 3:01 am
by jddantes
Why is mine not accepted?
Code: Select all
#include <stdio.h>
#include <string.h>
int main()
{
char number[1005];
while(fgets(number, 1005, stdin)!=NULL)
{
number[strlen(number)-1] = 0;
if(number[0] == '0' && number[1] == 0)
{
return 0;
}
int sum = 0;
int i = 0;
for(i=0; number[i];i++)
{
if(i%2 == 0)
{
sum+=number[i] - '0';
}
else
{
sum-=number[i] - '0';
}
//printf("%d %d\n",sum, number[i] - '0');
}
if (sum % 11 == 0)
{
printf("%s is a multiple of 11.\n",number);
}
else
{
printf("%s is not a multiple of 11.\n",number);
}
}
return 0;
}