-2
votes
0answers
45 views

Maximize the parts in which a large number can be decomposed in a limited time

Moderator's note: this question comes from the September CodeChef challenge which ends on Sep 15, 2014. The question will be locked until then. Problem: We have an large number n of long. ...
0
votes
0answers
596 views

Make beautiful Arithmetic progression [closed]

Moderator Note: This is a current contest question on codechef.com. Given an array that consists of $n$ integers, we have to change at most $k$ elements so that the resulting array will be a most ...
3
votes
0answers
32 views

The Basic Example and Output of Algorithms [closed]

if exg(x,y) swap the x,y, and array A contains integer numbers, the following algorithm how modify the $A[1]$ and what is the operation of the following algorithm? i confused to trace this code. any ...
2
votes
0answers
35 views

Add two a,b bits number Algorithm

Suppose we want add two numbers that has a and b bits. we do such operation in O(max{a,b}). we want to add n, 1 bit numbers (0 or 1). what is the best and worst case of this algorithm? i ran into ...
4
votes
0answers
51 views

local informatics Olympiad and Algorithm

I see one of recent local informatics Olympiad question. i have a trouble to solve it. any idea? hint? or solutions? thanks to all creative man. We have two function $P_1, P_2$ and input an array $n$ ...
2
votes
1answer
112 views

Water Box with n Liter

I ran into a basic challenging problem. I see an high school local math Olympiad question. we have a box that keep n Liter water. each time we extract 1/k Water from box. how many times (minimum) we ...
2
votes
1answer
26 views

Need an Algorithm Such that $\sum_{k-i}^{j}{A[k]}$

I need an algorithm for real application. Suppose we have array A (positive & negative ) numbers. we want to find index i, j such that $\sum_{k-i}^{j}{A[k]}$ has the lowest difference to zero. ...
2
votes
0answers
33 views

Can we sort 6 numbers with at most 9 comparison? [duplicate]

i know there is an algorithm to sort 5 numbers with 7 comparison. Can we sort 6 numbers with at most 9 comparison? thanks to all.
4
votes
3answers
93 views

2000 Olympiad in Informatics Question on Box

I have an old Olympiad question on informatics. There are 31 boxes. In each box there is one number. We know the number if and only if we open the box. We want to calculate the minimum number of ...
-2
votes
1answer
262 views

Modulo of a large sequence of $1$s

Given two numbers $N$ and $M$, we need to find the remainder when $111 \cdots1$ ($N$ times) is divided by $M$. Here $N$ can go up to $10^{16}$ and $M$ up to $10^9$. How to solve this problem? ...
2
votes
0answers
33 views

Speed dating/networking challenge

I am trying to organise an event with 54 participants. I want them to participate in 9 different activities at stations around a hall. Obviously this will require 9 sessions to allow the participants ...
0
votes
1answer
277 views

Select elements from N sets

N sets are given which can have any number of elements from 1-100 each.Now we need to count arrangements in which we select 1 element from each set under the condition that we can not choose same ...
2
votes
0answers
57 views

An algorithm for solving linear diophantine equations?

I am entering an interesting team based math contest called the purple comet, and quite a lot of questions on this contest involve Diophantine equations. For this contest, you are given a computer, ...
0
votes
0answers
47 views

Solving the recurrence $F(0) = X$ and $F(i)=A \cdot (F(i-1))^2 + B \cdot F(i-1) + C$

Moderator Note: This is a current contest question on codechef.com. I am given $F(0)=X$ and $F(i)=A \cdot (F(i-1))^2 + B \cdot F(i-1) + C$ for $1 \leq i \leq N$. Now given $N,A,B,C$ and $X$, how ...
-2
votes
2answers
191 views

Even or Odd for factorial

Moderator Note: This is a current contest question on codechef.com. Given $N$ and $M$ I need to tell whether $\left\lfloor \large\frac{N!}{M} \right\rfloor$ is even or odd.How to do this ...
1
vote
0answers
286 views

Finding the number of arrangement of N people of different height such that K of them are visible from front

Moderator Note: This is a current contest question on codechef.com. [Initially, I had asked this question in stackoverflow, but someone suggested to post it here, and hence this question is ...
4
votes
0answers
65 views

Minimizing the distance between points in two sets

Given two sets $A, B\subset \mathbb{N}^2$, each with finite cardinality, what's the most efficient algorithm to compute $\min_{u\in A, v\in B}d(u, v)$ where $d(u,v)$ is the (Euclidean) distance ...
3
votes
2answers
129 views

The number 3211000 is 7-special

Define a positive integer $k$ to be $n$-special if it satisfies the following properties: It has $n$ digits (0, 1, ..., 9) The 1st digit is equal to the number of 0's in the decimal representation ...
2
votes
2answers
104 views

Finding the index such that all partial sums are nonnegative

Given an array a[] of integers of arbitrary size N that sum to 0 (for example, a[] = {-1, 0, 5, 3, -9, 2}), does there always exists an index i ($0\le i\le N-1$) such that each partial sum $S_j = ...
0
votes
1answer
131 views

Minimum number of moves to equalize a list

Given a list of $n$ integers. In one move we can either decrease exactly one element by $1,2$ or $5$. What is the minimum number of moves required to equalize the list? For example: If the list is ...
1
vote
1answer
244 views

No of labeled trees with n nodes such that certain pairs of labels are not adjacent.

What is the number of trees possible with $n$ nodes where the $i$th and $(i+1)$th node are not adjacent to each other for $i \in \left[0,n-1\right)$ and $$i/2 = (i+1)/2.$$ (integer division) (nodes ...
1
vote
1answer
78 views

Vertex of a pentagon-Does the algorithm always stop?

To each vertex of a pentagon,we assign an integer $x_{i}$ with sum $s=\sum x_{i}>0$. If x,y,z are the numbers assigned to 3 successive vertices and if $y<0$,then we replace $(x,y,z)$ by ...
2
votes
2answers
215 views

How to factor 30 digit number

I need to find the prime factorization of a number having 30 digits. I used the Pollard rho method but unfortunately it is not sufficient enough. It needs a more advanced prime factorization ...
4
votes
1answer
547 views

Card Shuffling [SPOJ]

The original question is posted on SPOJ, and included below: Here is an algorithm for shuffling N cards: 1) The cards are divided into K equal piles, where K is a factor of N. 2) The ...
1
vote
2answers
109 views

Non-Standard Deviation

Given a list of integers, how to find the sum of the differences of all possible pairs of numbers ? For example if the number are $3,1,2$ then, answer should be $$\lvert 3-1 \rvert + \lvert 3 -2 ...
2
votes
1answer
274 views

Counting digits in an arithmetic sequence

Given $a, d, n, x$. Suggest me a suitable algorithm to compute the number of times the digit $x$ appearing in the arithmetic sequence $a, a + d, a + 2 \times d, \cdots, a + n \times d$. For ...
1
vote
1answer
2k views

Solving systems of linear congruences (modular equations)

This is a task from an old programming contest the task is as follows, A list of system of linear equations is given in the inputs.If the system is solvable we have to output the solution in the form ...
2
votes
2answers
306 views

Finding GCD of all permutations of a decimal number [duplicate]

Possible Duplicate: Computing GCD of all permutations (of the digits) of a given number. How can we find the greatest common divisor (GCD) of all numbers that can be obtained by permuting ...
4
votes
6answers
1k views

Finding the Heavy Coin by weighing twice

Suppose you have 100 coins. 96 of them are heavy and 4 of them are light. Nothing is known regarding the proportion of their weights. You want to find at least one genuine (heavy) coin. You are ...
5
votes
5answers
707 views

Least wasteful use of stamps to achieve a given postage

You have sheets of 42-cent stamps and 29-cent stamps, but you need at least $3.20 to mail a package. What is the least amount you can make with the 42- and 29-cent stamps that is ...