11344 - The Huge One

All about problems in Volume 113. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

hsn
New poster
Posts: 4
Joined: Thu Jan 24, 2008 12:56 am

11344 - The Huge One

Post by hsn »

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
greve
New poster
Posts: 27
Joined: Tue May 29, 2007 8:52 pm
Contact:

Post by greve »

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/
hsn
New poster
Posts: 4
Joined: Thu Jan 24, 2008 12:56 am

Post by hsn »

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....
greve
New poster
Posts: 27
Joined: Tue May 29, 2007 8:52 pm
Contact:

Post by greve »

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
For help with problems, visit http://www.uvatoolkit.com/
hsn
New poster
Posts: 4
Joined: Thu Jan 24, 2008 12:56 am

Post by hsn »

:D thanks a million for you help greve
Ron
Learning poster
Posts: 55
Joined: Mon Jul 23, 2007 5:01 pm
Location: INDIA

Re: 11344 - The Huge One

Post by Ron »

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.
Samiul
New poster
Posts: 36
Joined: Thu Dec 13, 2007 3:01 pm

Re: 11344 - The Huge One

Post by Samiul »

The first number tells you how many test cases are present.
calicratis19
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

Post by calicratis19 »

AC :D :D :D :D :) :) :lol: :lol:
Last edited by calicratis19 on Thu Apr 23, 2009 5:14 pm, edited 1 time in total.
Heal The World
newkid
Learning poster
Posts: 73
Joined: Fri Dec 12, 2008 3:06 am

Re: 11344 - The Huge One

Post by newkid »

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..
mukit
New poster
Posts: 48
Joined: Wed Nov 21, 2007 10:09 am
Location: Dhaka , Bangladesh
Contact:

Re: 11344 - The Huge One

Post by mukit »

I'm getting WA in this problem...Someone please give some I/O

Code: Select all

Accepted
Thank's in advance.
mukit
New poster
Posts: 48
Joined: Wed Nov 21, 2007 10:09 am
Location: Dhaka , Bangladesh
Contact:

Re: 11344 - The Huge One

Post by mukit »

Forget my previous post...it was a silly mistake.
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
Output:

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.
wallace
New poster
Posts: 10
Joined: Thu Feb 26, 2009 4:03 pm

Re: 11344 - The Huge One

Post by wallace »

16 - wonderful???
Why?
Att
wallace
New poster
Posts: 10
Joined: Thu Feb 26, 2009 4:03 pm

Re: 11344 - The Huge One

Post by wallace »

sorry,
I understand!
techbd123
New poster
Posts: 14
Joined: Tue Aug 06, 2013 3:42 pm

Re: 11344 - The Huge One

Post by techbd123 »

Please help.
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;
}
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11344 - The Huge One

Post by brianfry713 »

Try the I/O mukit posted in this thread.
Check input and AC output for thousands of problems on uDebug!
Post Reply

Return to “Volume 113 (11300-11399)”