Page 4 of 6
re
Posted: Mon Jan 29, 2007 7:20 pm
by ziliang
wow~ it's cool..
Posted: Tue Mar 20, 2007 6:54 pm
by Md.Arafat Hossain
your guess is right,try again carefully.
Re: WA in 10110
Posted: Wed Apr 04, 2007 9:05 pm
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?
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????????

Posted: Sat Jun 02, 2007 1:01 pm
by pradeepr
using long gives me a WA but when I use unsigned it got accepted..
donno the reason..
can someone please tell me??
Posted: Sat Jun 02, 2007 2:08 pm
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..
Posted: Wed Jul 18, 2007 3:42 pm
by newton
ohh that was a chilly mistake.
i am extremely sorry..
thank you very much.
Posted: Wed Jul 18, 2007 3:52 pm
by helloneo
You're welcome..

Re: 10110 - Light, More Light
Posted: Tue Jun 23, 2009 8:26 pm
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");
}
}
}
10110-Light more Light-in C
Posted: Tue Dec 08, 2009 3:27 pm
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;
}
Re: 10110 - Light, More Light
Posted: Tue Dec 15, 2009 4:46 pm
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...

Re: 10110-Light more Light-in C
Posted: Sun Dec 20, 2009 9:23 pm
by bollu
I found my mistake and gotAC.

10110 why WA? please any body help me
Posted: Sat Jul 31, 2010 7:55 am
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;
}
Re: 10110 why WA? please any body help me
Posted: Sat Oct 02, 2010 5:31 pm
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..

Re: 10110 - Light, More Light
Posted: Sat Nov 06, 2010 6:52 pm
by nb2.ruet
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;
}
Re: 10110 - Light, More Light
Posted: Fri Nov 12, 2010 7:23 am
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
regards
sauro