You need to take care of your health care. Dissolving them in water.
')
The man has a jar of pills and a jar of b pills. One day, he takes a pill from a jar of water. Then he accidentally takes out the water from the water. There are two pills, one pill and one pill. Unfortunately, the pills are thrown out of the question. How was the quantity of A and B?
Three Employees want to know the average of their salaries. Individual salaries. How can they calcalate average salary?
The number of natural numbers can be expressed. Two sequences are different.
Examples:
Input: 4
Output: 8
Explanation
All 8 position composition are:
4, 1 + 3, 3 + 1, 2 + 2, 1 + 1 + 2, 1 + 2 + 1, 2 + 1 + 1 and 1 + 1 + 1 + 1
Input: 8
Output: 128
The number of numbers in the decimal representation.
Examples:
Input: n = 10
Output: 9
Input: n = 45
Output: 31
// Numbers 3, 13, 23, 30, 31, 32, 33, 34,
// 35, 36, 37, 38, 39, 43 contain digit 3.
Input: n = 578
Oupt: 385
Write a program according to the following specifications:
Input: A array arr [] of two elements having value 0 and 1
Output: Make both elements 0.
Requirements: Following are specifications to follow.
1) It’s guaranteed that you’re not aware of its position.
2) We can't say about another element.
3) We can only complete the elements of, multi, division,…. etc.
4) We can't use if, else and loop constructs.
5) Obviously, can't get directly from 0 to array elements.
You need to add another pill A to the glass, mix and drink half a glass, leaving half the next day.
#include<iostream> using namespace std; #define ull unsigned long long ull countCompositions(ull n) { // Return 2 raised to power (n-1) return (1L) << (n-1); } // Driver Code int main() { ull n = 4; cout << countCompositions(n) << "\n"; return 0; }
#include <stdio.h> /* returns count of numbers which are in range from 1 to n and don't contain 3 as a digit */ int count(int n) { // Base cases (Assuming n is not negative) if (n < 3) return n; if (n >= 3 && n < 10) return n-1; // Calculate 10^(d-1) (10 raise to the power d-1) where d is // number of digits in n. po will be 100 for n = 578 int po = 1; while (n/po > 9) po = po*10; // find the most significant digit (msd is 5 for 578) int msd = n/po; if (msd != 3) // For 578, total will be 4*count(10^2 - 1) + 4 + count(78) return count(msd)*count(po - 1) + count(msd) + count(n%po); else // For 35, total will be equal to count(29) return count(msd*po - 1); } // Driver program to test above function int main() { printf ("%d ", count(578)); return 0; }
Source: https://habr.com/ru/post/350300/
All Articles