Thanks for the video but my problem is a little different with needs of optimization. Here is the problem acmp(dot)ru/index.asp?main=task&id_task=337 use google translate for translation.
I'm not really following you :/. I know that floor returns the largest integral value that's not greater than x, but I still don't get what you're saying. Maybe make a vid of this program using your method?
@hendrix5045 Ah I get what he's saying.For example, square root of 103 is 10.something. So it'll return 10. Floor rounds to the lowest integer. If it was 121, it would return 11 light bulbs on. But then it wouldn't show the light bulbs that were on. But then you could save that 11 on a variable, and say light bulbs x^2 until x=11 from 1. idk, knowing the explanation it just seems easier that way.
It would be simpler if you incremented j by k.
dejongbrent 11 months ago
why do you sound like...my ex boyfriend LMAO
hacksign000 2 years ago
Or another method without vectors is
int k = 1;
for int i=1 , i<N , i++ do
if i == k*k do
printf "1 " ;
k++ ;
endIfDo else printf "0 " ;
endForDo
Pseudo code because youtube don't want to display c++ code...
spider853 2 years ago
Thanks for the video but my problem is a little different with needs of optimization. Here is the problem acmp(dot)ru/index.asp?main=task&id_task=337 use google translate for translation.
spider853 2 years ago
A simpler program would just be to return the floor of the square root of n.
jachess89 2 years ago
I'm not really following you :/. I know that floor returns the largest integral value that's not greater than x, but I still don't get what you're saying. Maybe make a vid of this program using your method?
hendrix5045 2 years ago
khanacademy has the answer of this method.
So if you have a N of 100 the answer will be for (int i=1; i<=(int)sqrt(N); i++) {
lamps[i*i] = true;
}
spider853 2 years ago
@hendrix5045 Ah I get what he's saying.For example, square root of 103 is 10.something. So it'll return 10. Floor rounds to the lowest integer. If it was 121, it would return 11 light bulbs on. But then it wouldn't show the light bulbs that were on. But then you could save that 11 on a variable, and say light bulbs x^2 until x=11 from 1. idk, knowing the explanation it just seems easier that way.
JesusWey 11 months ago
niceeeee!
brilliantfranz 2 years ago
Thanks, so do you program at all?
hendrix5045 2 years ago
A bit, I learned with turbopascal (very old I know),
but i'll be grabbing some C++ tutorials/books this summer since i'll be having c/c++ classes in september
Your will videos will help a lot to start :-D
brilliantfranz 2 years ago
Awesome, good luck with C++!
hendrix5045 2 years ago