Page 3 of 5

Posted: Thu Aug 03, 2006 1:36 pm
by asif_rahman0

Code: Select all

Case #p: N is an Unhappy number.
May be need some spectacles. :wink:

rabbi

Posted: Sun Aug 13, 2006 3:22 pm
by savage
thanks asif,
yeah need some spectacles :o

Posted: Sun Aug 13, 2006 3:32 pm
by savage
Hello sanjana,

Code: Select all

Case #p: N is an Unhappy number. 
also u need sum spectacles :wink:
me also get WA for this line :roll:

rishan

Posted: Sun Aug 13, 2006 9:47 pm
by asif_rahman0
i think you should just follow the

Code: Select all

Copy & Paste method from the Output Section of problem
if you are not attentive!!!!!!

I solved this problem just Checking out for 4!!!!.

Posted: Fri Aug 18, 2006 12:50 pm
by kolpobilashi
thanks a lot guys :D
btw....i have already spectacles....seems the power got increased :-?

10591 WA!!

Posted: Fri Oct 06, 2006 11:17 am
by Daniele Furlan
Why this code is WA??? :cry: :cry: :cry:

Code: Select all

import java.io.*;

class Main {

    int[] square = new int[10];
    int[] mem = new int[1000];
    int ris=0;

    static String ReadLn (int maxLg)  // utility function to read from stdin
        {
            byte lin[] = new byte [maxLg];
            int lg = 0, car = -1;
            String line = "";

            try
            {
                while (lg < maxLg)
                {
                    car = System.in.read();
                    if ((car < 0) || (car == '\n')) break;
                    lin [lg++] += car;
                }
            }
            catch (IOException e)
            {
                return (null);
            }

            if ((car < 0) && (lg == 0)) return (null);  // eof
            return (new String (lin, 0, lg));
    }


    void TryHappyNumber() {

        String input;
        int val=0;
        int count=0;
        int step=0;
        int res;

        for (int i = 0; i < 10; i++) { //Calcolo quadrati "base"
            square[i] = i * i;
        }

        mem[1]=2;

        int k = Integer.parseInt(Main.ReadLn(255));
        count=k;
        val=0;

        int init=0;
        int[] valori = new int[count];

        while (val<count) {
            k = Integer.parseInt(Main.ReadLn(255));
            valori[val]=k;
            if (init==0) {
                res = isHappy(sum_cifre(k));
                val++;
                if (res==2) {
                    init=1;
                }
                else {
                    init=1;
                    step++; //Comincio a stampare dal successivo caso
                }
            }
            else {
                init=1;
                val++;
                res = isHappy(sum_cifre(k));
            }
        }


        for (int i=step; i<count; i++) {
            if (mem[sum_cifre(valori[i])]==2) {
                System.out.println("Case #" + (i+1-step) +": " + valori[i] + " is a Happy number.");
            }
            else {
                System.out.println("Case #" + (i+1-step) +": " + valori[i] + " is a Unhappy number.");
            }
        }
    }


    int isHappy(int n) {

        int k = sum_cifre(n);

        if ((mem[n] == 0)) {
            mem[n] = 3; //annoto che l'ho gi

Posted: Fri Oct 06, 2006 7:28 pm
by Daniele Furlan
Hello!!!

Raiyan Kamal's sample inputs is correct for my program.
I submit it but got WA. :( :(
Could anyone help me???

Code: Select all

#include <stdio.h>

	typedef long long int llint;

	void TryHappyNumber();
	llint isHappy(llint n);
	llint sum_cifre(llint n);

	llint square[10];
	llint mem[811];
	llint ris=0;


   void main() {

		llint count=0;
		llint res;
		llint k;
		llint i;

      for (i = 0; i < 10; i++) { //Calcolo quadrati "base"
         square[i] = i * i;
      }

      mem[1]=2;

		scanf( "%lld", &k );
      count=k;
     

		for (i=1; i<=count; i++) {
			scanf( "%lld", &k );
			res = isHappy(sum_cifre(k));
			printf( "Case #%lld: ", i );
			if (res==2) {
				printf( "%lld is a Happy number.\n", k );
         }
			else {
				printf( "%lld is a Unhappy number.\n", k );
         }
      }
	}


   //Trova se un numero

Posted: Mon Mar 12, 2007 3:47 pm
by newton
dear beloni
your algorithm is so nice.

okey now try this input.

Code: Select all


 2
 7
 7

may it will be helpfull to you.






newton........................................... simply the best

Posted: Sat Mar 01, 2008 8:59 am
by Saul Hidalgo
Hi to all! :wink:

I got WA. I review the format output, and all, but i got wa too. Here is my code.

Code: Select all

AC. Thanks Helloneo

THanks to all. Bye

Posted: Sat Mar 01, 2008 9:12 am
by helloneo
Try this input.. :-)

Code: Select all

1
4

My output..

Code: Select all

Case #1: 4 is an Unhappy number.

PS. Remove you code after AC.. :-)

Posted: Sat Mar 01, 2008 9:28 am
by Saul Hidalgo
helloneo wrote:Try this input.. :-)

Code: Select all

1
4

My output..

Code: Select all

Case #1: 4 is an Unhappy number.

PS. Remove you code after AC.. :-)
Hi Helloneo. Thanks for your quick answer. I got AC. :wink: :wink: Thanks.

10591 - help plz -Happy Number

Posted: Wed Dec 31, 2008 11:32 pm
by sazzadcsedu
whats wrong with my code??
why Runtime error??

Code: Select all

removed

Re: 10591 - Happy Number

Posted: Thu Jan 01, 2009 1:21 pm
by shiplu_1320
You should get RTE not WA because of this

Code: Select all

int arr[2000];
............
..........
if(arr[n]==1)
...............
where n can be much bigger than 2000.

Re: 10591 - Happy Number

Posted: Thu Jan 01, 2009 8:57 pm
by sazzadcsedu
thanx shiplu.
found the mistake & got accepted.

Re: 10591 - Happy Number

Posted: Mon Jan 05, 2009 6:44 am
by toru
PLZZ HELP !!!!!!!!!!!!!!!!!

Hi, How can i check for the repetative number for finding the unhappy number...........

Thanxx in advance

megh putra