10110 - Light, more light

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

Moderator: Board moderators

ziliang
New poster
Posts: 19
Joined: Sat Sep 30, 2006 2:50 pm

re

Post by ziliang »

wow~ it's cool..
不鸣则已,一鸣惊人.
Md.Arafat Hossain
New poster
Posts: 7
Joined: Fri Mar 02, 2007 10:20 am

Post by Md.Arafat Hossain »

your guess is right,try again carefully.
ranacse05
New poster
Posts: 37
Joined: Wed Mar 28, 2007 5:08 pm
Location: Rajshahi
Contact:

Re: WA in 10110

Post by ranacse05 »

eyeabhi wrote:I think if the number of bulbs is a perfect square, then answer is yes, otherwise no. Is my guess incorrect?

Code: Select all

deleted
I get WA every time. Plz anyone tell me whts wrong here?

I have solved the problem.


You try to solve it,
Its a very easy problem,how can u be student of BUET???????? :roll:
pradeepr
New poster
Posts: 21
Joined: Fri May 25, 2007 11:52 am
Location: India

Post by pradeepr »

using long gives me a WA but when I use unsigned it got accepted..
donno the reason..
can someone please tell me??
helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo »

pradeepr wrote:using long gives me a WA but when I use unsigned it got accepted..
donno the reason..
can someone please tell me??
long is 32bit signed integer and unsigned is 32bit unsigned integer..
So, if you don't use negative integers, unsigned int is 2 times bigger than long..
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Post by newton »

ohh that was a chilly mistake.

i am extremely sorry..




thank you very much.
Last edited by newton on Wed Jul 18, 2007 3:56 pm, edited 1 time in total.
helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo »

You're welcome.. :-)
foraml
New poster
Posts: 1
Joined: Tue Jun 23, 2009 8:19 pm

Re: 10110 - Light, More Light

Post by foraml »

here is my code
it gives WA
pls help...

Code: Select all

import java.io.*;
class light
{
        public static void main(String args[])throws Exception
        {
                DataInputStream dis= new DataInputStream(System.in);
                String ans="";
                int n;
                boolean flag=false;
                System.out.println("input:");
                while(true)
                {
                        n=Integer.parseInt(dis.readLine());
                       
                        if (n==0)
                        break;
                        flag=false;
                        for(int i=1;i<=n;i++)
                    {    if(n%i==0)
                        flag=(flag==true)?false:true;}

                        if(flag==true)
                        ans="1"+ans;
                        else
                        ans="0"+ans;
                }
                System.out.println("output:");
                for(int i=0;i<ans.length();i++)
                {
                        if(ans.charAt(i)=='1')
                        System.out.println("yes");
                        else
                        System.out.println("no");
                }
             }
         }
bollu
New poster
Posts: 3
Joined: Sun Dec 06, 2009 7:17 pm

10110-Light more Light-in C

Post by bollu »

When i submit this problem i getting TLE.Please help me!!
#include<stdio.h>
#include<math.h>
int main()
{
int t;
unsigned long int input;
double sq;
scanf("%d",&t);
while(t--)
{
scanf("%lu",&input);
sq=sqrt(input);
if(sq*sq==input)
printf("NO");
else
printf("YES");
}
return 0;
}
seraph
New poster
Posts: 9
Joined: Tue Dec 15, 2009 4:18 pm

Re: 10110 - Light, More Light

Post by seraph »

you can use floor and ceil function to solve this problem.

i just use :

if (floor(sqrt(n))==ceil(sqrt(n)))
cout<<"yes"<<endl;
else
cout<<"no"<<endl;

and i accepted...
:D :D :D
bollu
New poster
Posts: 3
Joined: Sun Dec 06, 2009 7:17 pm

Re: 10110-Light more Light-in C

Post by bollu »

I found my mistake and gotAC. :D :D
@mjad
New poster
Posts: 44
Joined: Thu Jul 22, 2010 9:42 am

10110 why WA? please any body help me

Post by @mjad »

#include<iostream>
#include<math.h>
using namespace std;

int divisable(unsigned long int n);
int main()
{
unsigned long int n;
int c;
double db;

while((cin>>n)&&n!=0){
db=sqrt(n);
if(db*db!=n)
cout<<"no"<<endl;
else
cout<<"yes"<<endl;
}

return 0;
}
Rashad
New poster
Posts: 17
Joined: Tue Dec 22, 2009 4:20 pm

Re: 10110 why WA? please any body help me

Post by Rashad »

I think changing "double db" with "unsigned long db" and "db=sqrt(n)" with "db=(unsigned long)sqrt(n)" will do. Hope you got AC by the time.. :)
nb2.ruet
New poster
Posts: 1
Joined: Sat Oct 30, 2010 11:52 am

Re: 10110 - Light, More Light

Post by nb2.ruet »

how ican avoid time limit exit ?any one help me please.......... :oops:

#include<stdio.h>

long int n,i,k=0;
int main()
{

while (1)
{
k=0;
scanf("%d",&n);
if (n==0)
break;
for (i=1;i<=n;i++)
{
if (n%i==0)
k++;
}
if (k%2==0)
printf("no\n");
else
printf("yes\n");
}
return 0;
}
sauro
New poster
Posts: 4
Joined: Mon Aug 30, 2010 11:26 pm
Location: BUET, bangladesh
Contact:

Re: 10110 - Light, More Light

Post by sauro »

hello nb2,
first of all, i think you should declare a bigger variable as long isn't sufficient enough to hold an integer of size (2^32-1) . . unsigned long will be enough.
2ndly, you are simulating the whole program where the problem is all about simple math! try checking whether the number is a perfect square . . if it is then the light will be turned on.

hope it helps :wink:

regards
sauro
all that we see or seem is but a dream within a dream
Post Reply

Return to “Volume 101 (10100-10199)”