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

  • Home
  • SEARCH
  • 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 855547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:05:31+00:00 2026-05-15T08:05:31+00:00

I have a set of given integers: A[] = { 2, 3, 4, 5,

  • 0

I have a set of given integers:

A[] = { 2, 3, 4, 5, 6, 7, 8, 10, 15, 20, 25, 30, 40, 50, 100, 500 }
  1. I want to check if a given integer T can be written as a multiple of the numbers in A[];
    EDIT CLARIFICATION:
    any number in A[] can be used.If used can be used only one time.
    EX 60 is a valid T.60=30*2.
    AlSO 90 is valid . 90=3*5*6

  2. Check which numbers can form that integer T.

  3. Also return the 2 closest integers to the given T (that can be written that way) if the number T cannot be written as a multiple of that numbers.

Parts 2 and 3, I think I can sort out of my own if someone helps me with part 1.

I know this is an algorithmic question or even a mathematical one but if anyone can help, please do.

NOT HOMEWORK. SEE COMMENT BELOW.

#

SOLUTION.
TY VERY MUCH FOR ALL ANSWERS.1 answer particulary (but the author choose to remove it and i don’t know really why since it was correct.)
Ty author (don’t remember your name.)

#

Solution Code with a twist(The author’s algorithm used multiple times one multiplier.This one uses multiplier only 1 time)

int oldT = 0;
        HashMap<Integer, Boolean> used = new HashMap<Integer, Boolean>();
        while (T != 1 && T != -1) {
            oldT = T;
            for (int multiple : A) {
                if (!used.containsKey(multiple)) {
                    if (T % multiple == 0) {
                        T = T / multiple;
                        used.put(multiple, true); 
                    }
                }
            }
            if (oldT == T)
                return false;
        }
        return true;
  • 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-15T08:05:32+00:00Added an answer on May 15, 2026 at 8:05 am

    If T is not very big (say, < 10^7), this is straight DP.

    a[1] = true; // means that number '1' can be achieved with no multipliers
    for (every multiplier x) {
       for (int i = T; i > 0; --i) {
          if (a[i] and (i * x <= T)) {
              // if 'i' can be achieved and 'x' is a valid multiplier,
              // then 'i * x' can be achieved too
              a[i * x] = true;
          }
       }
    }
    

    That’s assuming every multiplier can be used only once.
    Now, you can find decomposition of T if you have another array b[i] storing which multiplier was used to achieve i.

    There’s a lot of online content to get familiar with dynamic programming, if you have little time. It should give you idea how to approach such problems. For example, this one seems not bad
    http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=dynProg

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

Sidebar

Related Questions

I have a set of positive numbers. Given a number not in the set,
I have written a method to calculate a given percentile for a set of
I have a set of numbers produced using the following formula with integers 0
I have a class with a set of properties As given below. class ContactInfo
I have a set of checkboxes that an Admin can tick to give users
How can I give set foreign key value field in Entity Framework. I have
I want to find the first set of integers in an array X that
Given an input set of n integers in the range [0..n^3-1], provide a linear
I have been given a project to edit. I think this is a simple
I have to map a set of known integers to another set of known

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.