## 10110 - Light, more light

Moderator: Board moderators

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

### re

wow~ it's cool..

Md.Arafat Hossain
New poster
Posts: 7
Joined: Fri Mar 02, 2007 10:20 am
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

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????????

New poster
Posts: 21
Joined: Fri May 25, 2007 11:52 am
Location: India
using long gives me a WA but when I use unsigned it got accepted..
donno the reason..

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea
pradeepr wrote:using long gives me a WA but when I use unsigned it got accepted..
donno the reason..
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
Contact:
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
You're welcome..

foraml
New poster
Posts: 1
Joined: Tue Jun 23, 2009 8:19 pm

### Re: 10110 - Light, More Light

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)
{

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

#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

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...

bollu
New poster
Posts: 3
Joined: Sun Dec 06, 2009 7:17 pm

### Re: 10110-Light more Light-in C

I found my mistake and gotAC.

New poster
Posts: 44
Joined: Thu Jul 22, 2010 9:42 am

### 10110 why WA? please any body help me

#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;
}

New poster
Posts: 17
Joined: Tue Dec 22, 2009 4:20 pm

### Re: 10110 why WA? please any body help me

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

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

#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