Check for even or odd [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Given N amd M how to check whether floor value of N!/M will be even value or odd value where N can go upto 10^5 and M can go upto 10^18.
Please help to check this condition in efficient way.
EDIT
My attempt : I first think of breaking N!=(2^a)(some odd value) and similarly for M but as the odd value of N! can be very large so i was thinking of some better solution.

Related

Haskell finding mean of cubes of odd members Any ideas? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Please find the mean of cubes of odd members of given list of Int type.
Try to use (.), ($), map, filter or foldl (You should use at least one of them).
I would give you some hints to get you started up:
Use filter function to get the odd members of the given list.
Cube the resultant list using map function.
Find the mean of them by summing the list and dividing it by the length of the list.
The only thing I would add to the other comments and answers is the use of fromIntegral to convert the Int type to Fractional for using the (/) operator.

How do I get the 10 lowest values in an array? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I have an array of type double. How do I get the 10 lowest values?
double values[1000];
This is what I've come up before:
double similar[num_img];
copy(begin(values), end(values), begin(similar)); //copy values to another variable
int elements = sizeof(similar) / sizeof(similar[0]);
sort(similar, similar + elements);
So that I could get the 10 values. But what I'm actually after is the indices.. So sorting it would not help, I guess.
Sort the array and grab the first 10 elements (values[0] through values[9]).

Calculating large numbers in C++ without external libraries [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I need to write a program that will perform operations on float numbers higher than 10^100.
I can't use any arbitrary precision mathematics libraries that are not included in GCC package by default.
I have NO idea how how to go about it.
Can you point me in the right direction?
You can create a class that can store larger numbers. 12345678 equals to 1234 * 10e4 + 5678.
For large numbers I use string buffers and do manual computation on it. It is much overhead and slow but you get infinite precision.

Regex Binary multiple of 4 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How can I write a Reg-ex Expression to check whether a string is a binary multiple of 4? I am not good at making DFA and finding expressions.
A multiple of 4 in binary is any binary number that ends with 00, so this regexp should do it:
^(?:[10]*00|00?)$
If you mean a multiple of 4 in decimal, I wouldn't do that with a regexp, except perhaps to verify that it's a number. Then I'd parse it and check whether number % 4 is zero.

Finding value of int x [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
int x;
x=x+30;
cout << x;
the output will be 33, why is it so?
I didn't even declare x as 3.
Can someone guides me? Thanks!
Using an uninitialized variable is undefined behavior. You got 33 due to an unreliable sequence of implementation quirks. The program is free to produce any value at all, fail to compile, or hire an assassin to stab you.
In C++, variables are given space (memory allocation) by default equal to the size of the variable, but they are not given values by default.