Added: 2 years ago
From: hendrix5045
Views: 828
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:
see all

All Comments (9)

Sign In or Sign Up now to post a comment!
  • It would be simpler if you incremented j by k.

  • why do you sound like...my ex boyfriend LMAO

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

  • 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=tas­k&id_task=337 use google translate for translation.

  • A simpler program would just be to return the floor of the square root of n.

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

  • 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;

    }

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

  • niceeeee!

  • Thanks, so do you program at all?

  • 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

  • Awesome, good luck with C++!

Loading...
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more