Page 13 of 15

Re: 10013 - Super Long Sums

Posted: Fri Jun 08, 2012 10:03 pm
by brianfry713
On the sample I/O, you are missing the newline at the end of the last line of the output.

Re: 10013 - Super Long Sums

Posted: Sat Jun 09, 2012 1:54 pm
by uvasarker
Thanks a lot boss.
I got AC

Re: 10013 - Super Long Sums

Posted: Sun Sep 30, 2012 12:11 pm
by chromeos722
Hi,
Runtime error. Tottally don't know why. Please help.

Code: Select all

#include <stdio.h>

long a[1000001];
long b[1000001];
long sum[1000001];

int main(){

	int count;
	int digit[1000];
	digit[0] = 0;
	int size = 0;

	scanf("%d", &count);
	printf("\n");

	for(int i = 0; i < count; i++){
		scanf("%d", &digit[i+1]);
		digit[i+1] += digit[i];

		for(int j = digit[i]; j < digit[i+1]; j++){
			scanf( "%d %d", &a[j+1], &b[j+1] );
		}
		digit[i+1] += 1;
		printf("\n");
	}

	for(int i = 0; i < count; i++){
		int j = digit[i+1]-1;
		int temp;
		do 
		{
			if(sum[j+1] == 10){
				sum[j+1] = 0;
				sum[j] += 1;
			}

			if( a[j] + b[j] >= 10 ){
				temp = (a[j] + b[j]) % 10;
				sum[j] += temp;
				sum[j -1] = 1;
			}

			else{
				sum[j] += a[j] + b[j];
			}

			j--;
		}while (j != digit[i]);
	}

	for(int i = 0; i < count; i++){
		for(int j = digit[i]; j <digit[i+1]; j++){
			if(j == digit[i] && sum[j] == 0){
				j++;
			}
			printf("%d", sum[j]);
		}
		if(i != count - 1){
			printf("\n\n");
		}
		else{
			printf("\n");
		}
	}

	return 0;
}

Re: 10013 - Super Long Sums

Posted: Mon Oct 01, 2012 9:43 pm
by brianfry713
Print the results for each test case right away, don't try and store all the results.

Re: 10013 - Super Long Sums(WA Y??)

Posted: Sun Oct 21, 2012 12:35 pm
by sonjbond
why i am getting WA ?? plz help me .....
my code is here :

Code: Select all

#include<stdio.h>
#include<string.h>
int num1[1000010],num2[1000010],sum[1000015];
int main()
{
    long tc;
    scanf("%ld",&tc);
    while(tc--)
    {
        //printf("\n");
        long i,j,k,m,n,rem;
        scanf("%ld",&n);
        for(i=0; i<n; i++)
            scanf("%d %d",&num1[i],&num2[i]);
        rem=0;
        for(i=n-1; i>=0; i--)
        {
            m=num1[i]+num2[i]+rem;
            sum[i]=m%10;
            rem=m/10;
        }
        /*if(rem!=0)
        {
            printf("%ld",rem);
        }*/
        for(i=0; i<n; i++)
            printf("%d",sum[i]);
        if(tc)printf("\n");

    }
    return 0;
}

plz help meeeeeeeeee :( :( :( :( :( :( :( :( :( :(

Re: 10013 - Super Long Sums

Posted: Tue Oct 23, 2012 10:34 pm
by brianfry713
There is a blank line between output blocks.

10013 - Super long sums,i got it WA more time

Posted: Fri Jan 11, 2013 11:13 am
by naim
#include<stdio.h>
#include<string.h>
int a[1000001],b[1000001],sum1[1000001];
int main()
{

long int t,m,i,j,sum;
scanf("%ld",&t);
for(i=0;i<t;i++)
{
scanf("%ld",&m);
for(j=0;j<m;j++)
scanf("%d %d",&a[j],&b[j]);
sum=0;
for(j=m-1;j>=0;j--)
{
sum=a[j]+b[j]+sum;
sum1[j]=sum%10;
sum=sum/10;
}
for(j=0;j<m;j++)
{
printf("%d",sum1[j]);

}
printf("\n\n");
}
return 0;
}
:(

Re: 10013 - Super long sums,i got it WA more time

Posted: Fri Jan 11, 2013 8:35 pm
by brianfry713
There is a blank line between output blocks.
Don't print a blank line after the last output.

10013- Super long sums-again & again WA plz help...

Posted: Mon Jan 14, 2013 6:45 pm
by naim
#include<stdio.h>
#include<string.h>
int a[1000001],b[1000001],sum1[1000001];
int main()
{

long int t,m,i,j,sum;
scanf("%ld",&t);
printf("\n");
for(i=0;i<t;i++)
{
scanf("%ld",&m);
for(j=0;j<m;j++)
scanf("%d %d",&a[j],&b[j]);
sum=0;
for(j=m-1;j>=0;j--)
{
sum=a[j]+b[j]+sum;
sum1[j]=sum%10;
sum=sum/10;
}
for(j=0;j<m;j++)
{
printf("%d",sum1[j]);

}
if(i==0)
printf("\n");
}
return 0;
}
:oops:

Re: 10013- Super long sums-again & again WA plz help...

Posted: Mon Jan 14, 2013 9:46 pm
by brianfry713
For the sample input you're printing "\n4750\n470". It should be "4750\n\n470\n"

Re: 10013 - Super Long Sums

Posted: Sat May 25, 2013 6:29 pm
by shaon_cse_cu08
Hello.. plzzz Help.. I don't know But every times i m submitting i m getting Submission Error... :x
I don't knw whats the problem... and for my entire UVa lifetime i hv never got an Submission Error (What is this!!)...
Its Driving me creazy... :oops: PLZ Help!!!

Code: Select all

import java.math.BigInteger;
import java.util.Scanner;


public class Main
{
    public static void main(String args[])
    {
        Scanner inp = new Scanner(System.in);
        
        long n,m,x,y,i;
        
        n = inp.nextLong();
        
        while(n>0)
        {
            String a = new String();
            String b = new String();
           
            m = inp.nextLong();
            
            for(i =0; i<m; i++)
            {
                x = inp.nextLong();
                y = inp.nextLong();
                
                a += ""+x;
                b += ""+y;
            }
            
            BigInteger aa = new BigInteger(a);
            BigInteger bb = new BigInteger(b);
            
            System.out.println(aa.add(bb));
            
            
            n--;
            
            if(n>0)
                System.out.println();
        }
         
    }
}

10013 - Super Long Sum (Submission Error!!!)

Posted: Mon May 27, 2013 12:14 pm
by shaon_cse_cu08
Hello.. plzzz Help.. I don't know But every time i m submitting i m getting Submission Error... :x
I don't knw whats the problem... and for my entire UVa lifetime i hv never got an Submission Error (What is this!!)...
Its Driving me creazy... :oops: PLZ Help!!!

Code: Select all

import java.math.BigInteger;
import java.util.Scanner;


public class Main
{
    public static void main(String args[])
    {
        Scanner inp = new Scanner(System.in);
        
        long n,m,x,y,i;
        
        n = inp.nextLong();
        
        while(n>0)
        {
            String a = new String();
            String b = new String();
           
            m = inp.nextLong();
            
            for(i =0; i<m; i++)
            {
                x = inp.nextLong();
                y = inp.nextLong();
                
                a += ""+x;
                b += ""+y;
            }
            
            BigInteger aa = new BigInteger(a);
            BigInteger bb = new BigInteger(b);
            
            System.out.println(aa.add(bb));
            
            
            n--;
            
            if(n>0)
                System.out.println();
        }
         
    }
}

Re: 10013 - Super Long Sum (Submission Error!!!)

Posted: Tue May 28, 2013 11:47 pm
by brianfry713
There are a lot of submission errors lately. Try a different problem for now.

Re: 10013 - Super Long Sums

Posted: Tue May 28, 2013 11:49 pm
by brianfry713
There are a lot of submission errors lately. Try a different problem for now.

Re: 10013 - Super Long Sums

Posted: Sat Nov 09, 2013 3:52 am
by techbd123
Please help Guru Brainfry! Why getting WA?

Code: Select all

#include <stdio.h>

short int sum[1000001],crry[1000001];
unsigned char numstr[1000001];

int main()
{
    int i,t,n,c,f=0;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        i=n;
        while(i--)
        {
            scanf("%d",&c);sum[i]=c;scanf("%d",&c);sum[i]+=c;
            if(sum[i]>9){sum[i]-=10;crry[i]=1;}
            else crry[i]=0;
        }
        for(i=0;i<n;i++)
        {
            if(i>0) sum[i]+=crry[i-1];
            if(sum[i]>9)
            {
                sum[i]-=10;
                crry[i]++;
            }
            numstr[n-i-1]=sum[i]+48;
        }
        numstr[i]=0;
        if(f) printf("\n%s\n",numstr);
        else {printf("%s",numstr);f=1;}
    }
    return 0;
}