All about problems in Volume 109. If there is a thread about your problem, please use it. If not, create one with its number in the subject.
Moderator: Board moderators
Faithkeeper_Rangwan
New poster
Posts: 12 Joined: Sun Jul 07, 2013 7:32 pm
Post
by Faithkeeper_Rangwan » Sun Jul 07, 2013 7:40 pm
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
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Mon Jul 08, 2013 11:52 pm
Check input and AC output for thousands of problems on
uDebug !
woaraka92
New poster
Posts: 9 Joined: Sun Oct 20, 2013 6:50 pm
Post
by woaraka92 » Sun Oct 20, 2013 7:28 pm
#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;
}
woaraka92
New poster
Posts: 9 Joined: Sun Oct 20, 2013 6:50 pm
Post
by woaraka92 » Sun Oct 20, 2013 7:33 pm
whats the problem in this code?
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Mon Oct 21, 2013 9:25 pm
110 is a multiple of 11.
Check input and AC output for thousands of problems on
uDebug !
woaraka92
New poster
Posts: 9 Joined: Sun Oct 20, 2013 6:50 pm
Post
by woaraka92 » Wed Oct 23, 2013 9:18 pm
Thanks brianfry713..
jddantes
Learning poster
Posts: 73 Joined: Sat Mar 08, 2014 8:55 am
Post
by jddantes » Thu Mar 13, 2014 10:00 pm
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;
}
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Fri Mar 14, 2014 9:02 pm
That is AC code.
Yes they mean positive integers.
Check input and AC output for thousands of problems on
uDebug !
jddantes
Learning poster
Posts: 73 Joined: Sat Mar 08, 2014 8:55 am
Post
by jddantes » Sun Mar 16, 2014 1:22 pm
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;
}
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Mon Mar 17, 2014 9:55 pm
That is AC code.
Check input and AC output for thousands of problems on
uDebug !
uDebug
A great helper
Posts: 475 Joined: Tue Jul 24, 2012 4:23 pm
Post
by uDebug » Mon Mar 24, 2014 7:38 am
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.
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Tue Mar 25, 2014 12:15 am
There probably aren't spaces in the judge's input.
Check input and AC output for thousands of problems on
uDebug !
uDebug
A great helper
Posts: 475 Joined: Tue Jul 24, 2012 4:23 pm
Post
by uDebug » Tue Mar 25, 2014 8:14 am
brianfry713 wrote: There probably aren't spaces in the judge's input.
That makes sense. Thanks.
jddantes
Learning poster
Posts: 73 Joined: Sat Mar 08, 2014 8:55 am
Post
by jddantes » Sun Mar 30, 2014 3:01 am
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;
}