Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7171577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:26:29+00:00 2026-05-28T15:26:29+00:00

I am having the following problem that I cannot solve. Let’s say I have

  • 0

I am having the following problem that I cannot solve.
Let’s say I have an array of 100 bools, all false.
I have a number N < 100 and I want to toggle N of these booleans to true, but so that they appear as regularly spaced as possible.
This is obviously simple when N divides 100, but how to do it for instance if N = 53?
I naively tried :

for(int i =0; i<53; ++i)
    std::cout << i*100/53 <<'\n';

to get 53 equaly distributed integers, and in this case I actualy have distincts integers, but I’m not sure this always works. Any pointers on this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:26:30+00:00Added an answer on May 28, 2026 at 3:26 pm

    For the method you suggest, you will always get distinct integers for i * 100/X and (i + 1) * 100/X as long as X < 100 (as the difference is 100/X, which is > 1). So it’s a simple proof by induction that all the integers you obtain this way are unique.

    So this is a fine approach. The real question, which only you can answer, is how do you define equally distributed integers?

    Perhaps for X > 2, you should always have i[0] and i[99] set to true and divide the space in between equally. For the special case of X = 1, set the middle element (50th or 51st) to true.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been having the following problem, i think it's probably due to the
I have a query,and I am having the following error returned however I cannot
I am having the problem that I cannot select a specific XML node which
I ran into the following problem and cannot decide how to proceed: I have
I'm having the following problem: cannot convert from 'MyProject.DataLayerServiceRef.MyDTO' to 'WCFService.MyDTO' when i'm trying
I am having a problem that I cannot figure out. I am using the
I'm having following problem. I should convert a control to a certain type, this
I'm having the following problem. I created a application context file for spring.net. The
I'm having the following problem and wondered whether anyone could see why this is
I'm having the following problem using the Visual Studio 2010 Team System Beta 1:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.