Click here to Skip to main content
15,887,175 members
Home / Discussions / Algorithms
   

Algorithms

 
QuestionAlgorithm query + request Pin
Member 1214387716-Nov-15 6:53
Member 1214387716-Nov-15 6:53 
AnswerRe: Algorithm query + request Pin
Chris Losinger16-Nov-15 7:01
professionalChris Losinger16-Nov-15 7:01 
AnswerRe: Algorithm query + request Pin
Patrice T17-Nov-15 18:00
mvePatrice T17-Nov-15 18:00 
GeneralHash table load factor Pin
Member 1180386012-Nov-15 13:04
Member 1180386012-Nov-15 13:04 
QuestionAlgorithm needed to find a point on A4 size plane Pin
Member 1213438812-Nov-15 3:45
Member 1213438812-Nov-15 3:45 
AnswerRe: Algorithm needed to find a point on A4 size plane Pin
Richard Deeming12-Nov-15 4:05
mveRichard Deeming12-Nov-15 4:05 
AnswerRe: Algorithm needed to find a point on A4 size plane Pin
Chris Maunder12-Nov-15 4:15
cofounderChris Maunder12-Nov-15 4:15 
QuestionFastest way to count nested loops Pin
Member 113783027-Nov-15 2:32
Member 113783027-Nov-15 2:32 
Im inputing three numbers of users choice
number 1
number 2
final number

what i want to find out is , how many combinations of number 1 and number 2 would result in final number = number1 *x + number2*y = final number.

I am using nested loops

Objective-C
int i;
int j;
long long int pocet=0; // the numbers of combination
long long int one; // first number inputed by user
long long int two; // second number inputed by user
long long int last; // final number inputed by user - wanted result
long long int one_max;
long long int two_max;
long long int add=1; //for incrementing loops
long long int reduc=1; // for decrementing loops

if((one%2==0) && (two%2==0)){
        if(one>two){
            add=two/2;
            reduc=one/2;
    }
}
one_max=last/one;
two_max=last/two;
for(i=0;i<=one_max;i+=add){
    for(j=two_max;j>=0;j-=reduc){
        long long int tmp_one=(one*i);
        long long int tmp_two=(two*j);
            if(tmp_one+tmp_two==last){
                two_max=j;
                pocet++;
        }
    }
}

if i input these numbers
one = 10;
two = 13;
final =100;
the only possible combination of first two numbers to result in final number is
10 * 10 + 13 * 0

modified 7-Nov-15 11:37am.

AnswerRe: Fastest way to count nested loops Pin
Patrice T7-Nov-15 4:57
mvePatrice T7-Nov-15 4:57 
GeneralRe: Fastest way to count nested loops Pin
Member 113783027-Nov-15 5:02
Member 113783027-Nov-15 5:02 
GeneralRe: Fastest way to count nested loops Pin
PIEBALDconsult7-Nov-15 5:18
mvePIEBALDconsult7-Nov-15 5:18 
GeneralRe: Fastest way to count nested loops Pin
Member 113783027-Nov-15 5:36
Member 113783027-Nov-15 5:36 
GeneralRe: Fastest way to count nested loops Pin
Patrice T7-Nov-15 7:51
mvePatrice T7-Nov-15 7:51 
GeneralRe: Fastest way to count nested loops Pin
Patrice T7-Nov-15 8:16
mvePatrice T7-Nov-15 8:16 
GeneralRe: Fastest way to count nested loops Pin
Member 113783027-Nov-15 8:27
Member 113783027-Nov-15 8:27 
GeneralRe: Fastest way to count nested loops Pin
Patrice T7-Nov-15 8:52
mvePatrice T7-Nov-15 8:52 
GeneralRe: Fastest way to count nested loops Pin
Member 113783027-Nov-15 9:08
Member 113783027-Nov-15 9:08 
GeneralRe: Fastest way to count nested loops Pin
Patrice T7-Nov-15 9:19
mvePatrice T7-Nov-15 9:19 
GeneralRe: Fastest way to count nested loops Pin
harold aptroot7-Nov-15 5:20
harold aptroot7-Nov-15 5:20 
AnswerRe: Fastest way to count nested loops Pin
Luc Pattyn3-Jan-16 6:37
sitebuilderLuc Pattyn3-Jan-16 6:37 
Questionhow do you calculate a primitive operation in algorithm analysis Pin
Member 118975665-Nov-15 21:15
Member 118975665-Nov-15 21:15 
AnswerRe: how do you calculate a primitive operation in algorithm analysis Pin
Richard Deeming6-Nov-15 2:02
mveRichard Deeming6-Nov-15 2:02 
GeneralRe: how do you calculate a primitive operation in algorithm analysis Pin
Member 118975666-Nov-15 2:57
Member 118975666-Nov-15 2:57 
GeneralRe: how do you calculate a primitive operation in algorithm analysis Pin
Richard Deeming6-Nov-15 3:03
mveRichard Deeming6-Nov-15 3:03 
GeneralRe: how do you calculate a primitive operation in algorithm analysis Pin
jschell7-Nov-15 6:18
jschell7-Nov-15 6:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.