11344 - The Huge One
Moderator: Board moderators
11344 - The Huge One
i would really be thankful if you guys gave me some I/Os. because i have written this code but the problem is i keeping getting WA
thanks in advance
thanks in advance
It might be because the first number on the line with the set S is not a member of S, but instead the number of elements in the set S (I missed this detail and got several WAs). Otherwise you can make your own input and check the output on my page http://uva.xgd.dk
For help with problems, visit http://www.uvatoolkit.com/
thanks alot for the website.
and thank for the hint about the first number after M.
but it i still getting WA
i think because in the question it says that 0<=M<=10^1000
WHEN I try to store 10^100 it gives me wrong numbers
if you can tell me how to avoid OVERFLOW in this condition
thanks alot in advance
hsn....
and thank for the hint about the first number after M.
but it i still getting WA
i think because in the question it says that 0<=M<=10^1000
WHEN I try to store 10^100 it gives me wrong numbers
if you can tell me how to avoid OVERFLOW in this condition
thanks alot in advance
hsn....
Use properties of modulo to calculate the remainder (and avoid overflow).
If we store the number as a string, we can calculate the remainder as we read the string starting from the most significant end. Here is an example. Say the number is 12345 and k is 6, then we calculate:
for the empty string the remainder is 0
for the string 1 the remainder is now (0*10 + 1) % 6 = 1
for the string 12 the remainder is now (1*10 + 2) % 6 = 0
for the string 123 the remainder is now (0*10 + 3) % 6 = 3
for the string 1234 the remainder is now (3*10 + 4) % 6 = 4
for the string 12345 the remainder is now (4*10 + 5) % 6 = 3
so we have that 12345 mod 6 = 3
If we store the number as a string, we can calculate the remainder as we read the string starting from the most significant end. Here is an example. Say the number is 12345 and k is 6, then we calculate:
for the empty string the remainder is 0
for the string 1 the remainder is now (0*10 + 1) % 6 = 1
for the string 12 the remainder is now (1*10 + 2) % 6 = 0
for the string 123 the remainder is now (0*10 + 3) % 6 = 3
for the string 1234 the remainder is now (3*10 + 4) % 6 = 4
for the string 12345 the remainder is now (4*10 + 5) % 6 = 3
so we have that 12345 mod 6 = 3
For help with problems, visit http://www.uvatoolkit.com/
Re: 11344 - The Huge One
why WA....help plzz
Code: Select all
Oh !! very small mistake...
thnx Samiul
Now accepted...
Last edited by Ron on Wed Aug 27, 2008 9:49 pm, edited 2 times in total.
Re: 11344 - The Huge One
The first number tells you how many test cases are present.
-
- Learning poster
- Posts: 76
- Joined: Mon Jul 21, 2008 8:50 am
- Location: SUST,SYLHET,BANGLADESH.
- Contact:
11344 - The Huge One.. help me plz.WA
AC
![:lol:](./images/smilies/icon_lol.gif)
![:D](./images/smilies/icon_biggrin.gif)
![:D](./images/smilies/icon_biggrin.gif)
![:D](./images/smilies/icon_biggrin.gif)
![:D](./images/smilies/icon_biggrin.gif)
![:)](./images/smilies/icon_smile.gif)
![:)](./images/smilies/icon_smile.gif)
![:lol:](./images/smilies/icon_lol.gif)
![:lol:](./images/smilies/icon_lol.gif)
Last edited by calicratis19 on Thu Apr 23, 2009 5:14 pm, edited 1 time in total.
Heal The World
Re: 11344 - The Huge One
There is a problem with the description. the first number of the second line denotes how many numbers are in the set. although the description just says "Second line contains a set S. Numbers of this set are separated by a space character."
hmm..
Re: 11344 - The Huge One
I'm getting WA in this problem...Someone please give some I/O
Thank's in advance.
Code: Select all
Accepted
Re: 11344 - The Huge One
Forget my previous post...it was a silly mistake.
whatever here is some I/O for help
Input:
Output:
whatever here is some I/O for help
Input:
Code: Select all
13
16
3 2 4 8
2982752926433280000
12 1 2 3 4 5 6 7 8 9 10 11 12
8888888888
1 2
16944708
1 3
501988
1 4
6182945
1 5
7415934
1 6
87965423
1 7
45476438152
1 8
511612461
1 9
565645890
1 10
6213620589
1 11
545493751068
1 12
Code: Select all
16 - Wonderful.
2982752926433280000 - Wonderful.
8888888888 - Wonderful.
16944708 - Wonderful.
501988 - Wonderful.
6182945 - Wonderful.
7415934 - Wonderful.
87965423 - Wonderful.
45476438152 - Wonderful.
511612461 - Wonderful.
565645890 - Wonderful.
6213620589 - Wonderful.
545493751068 - Wonderful.
Re: 11344 - The Huge One
16 - wonderful???
Why?
Att
Why?
Att
Re: 11344 - The Huge One
sorry,
I understand!
I understand!
Re: 11344 - The Huge One
Please help.
Why WA in this code????
Why WA in this code????
Code: Select all
#include <stdio.h>
unsigned char str[10010];
struct sum_length_rsum
{
int sum,length,rsum;
};
struct sum_length_rsum SumStr(unsigned char str[])
{
int i,sum,rsum;struct sum_length_rsum x;for(i=rsum=sum=0;str[i];i++) {sum+=str[i]-'0';if(i&0x0001)rsum-=str[i]-'0';else rsum+=str[i]-'0';}
x.sum=sum;x.length=i;x.rsum=rsum;
return x;
}
int Divisible7(unsigned char str[],int length)
{
int i,c,sum;for(i=sum=0;i<length;i++)
{
if(c=i%6)
{
if(c==1) sum+=3*(str[length-i-1]-'0');
else if(c==3) sum+=6*(str[length-i-1]-'0');
else {sum+=c*(str[length-i-1]-'0');sum%=7;}
}
else sum+=str[length-i-1]-'0';
}
if(sum%7) return 0;
else return 1;
}
int main()
{
int i,j,t,n,f,state,div[13]; struct sum_length_rsum x;
scanf("%d",&t);
while(t--)
{
scanf("%s",str);scanf("%d",&j);
x=SumStr(str);
if(str[0]=='0'&&str[1]==0) {for(i=0;i<j;i++) scanf("%d",&n);printf("%s - Wonderful.\n",str);}
else
{
for(div[0]=div[1]=1,i=2;i<13;i++) div[i]=0;
if(str[x.length-1]&0x0001);
else
{
if(x.length>1) f=(str[x.length-2]-'0')*10+(str[x.length-1]-'0');else f=str[x.length-1]-'0';
if(f&0x0003)div[2]=1;
else if((f/4)&0x0001) div[2]=div[4]=1;
else div[2]=div[4]=div[8]=1;
}
if(x.sum%3);else if(x.sum%9){div[3]=1;}else {div[3]=div[9]=1;}
if(div[2]==1&&div[3]==1) div[6]=1;
if(div[4]==1&&div[3]==1) div[12]=1;
if((str[x.length-1]=='0')||(str[x.length-1]=='5')) div[5]=1;
if(div[2]==1&&div[5]==1) div[10]=1;
if(x.rsum%11==0) div[11]=1;
for(i=0,f=state=1;i<j;i++)
{
scanf("%d",&n);
if(state)
{
if(n==7&&f)
{
if(Divisible7(str,x.length)) div[7]=1;
f=0;
}
if(div[n]!=1) state=0;
}
}
if(state) printf("%s - Wonderful.\n",str);
else printf("%s - Simple.\n",str);
}
}
return 0;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11344 - The Huge One
Try the I/O mukit posted in this thread.
Check input and AC output for thousands of problems on uDebug!