Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all 39796 articles
Browse latest View live

Arranging Cup-cakes


Bleak Numbers

$
0
0

Bleak Numbers

In Mathematics each number has one special number, which it supports, chosen as follows. It counts the number of ones in its own binary representation, and adds this count to itself to obtain the value of the number it supports. That is, if j(m) means the number of ones in the binary representation of m, then m supports m+j(m). For example, the number eight (1000 in binary) supports nine, whereas nine supports eleven.

However, in this way not all the numbers get supported; some are left without support, and we call these numbers bleak. For example since one supports two, two supports three and three supports five, there is no number less than four, which would support four, so four is bleak.

Your task is for a given number recognize if it is bleak or supported by some number.

How to solve this question

GAMES, SPOJ WA

$
0
0

I am getting WA in GAMES. My code is

#include <cstdio>
using namespace std;
main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
    double avg;
    scanf("%lf",&avg);
    avg*=10000;

    long long b=static_cast<long long>(avg);
    //printf("%lf %lld\n",avg,b);
    long long a=10000;
    while(b%a!=0)
    {
        long long tmp=b%a;
        b=a;
        a=tmp;
    }
    printf("%lld\n",10000/a);
    }
    return 0;
}

I want to this, without using string. I am also not using any comparision with the float variables, so no error whatsoever should crop up due to using, float. Am I correct ??

"C" Program of Binary Search using "Function" ?

$
0
0

Hi,

Can anybody help me using the Algorithm i.e. programming code of "BINARY SEARCH" using "Function" only and not "recursion" ??

Any detailed reply shall be highly appreciable ?

Awaiting here ?

Thanks & Regards,

RIYA ROY [KOLKATA, WEST BENGAL, INDIA]

Is there any reason why -O3 is not used or unable to be set?

$
0
0

In practice, I cannot see any reason why it would be explicitly disallowed (I haven't used -O2 as far back as I can remember); it also discourages doing silly and minor optimizations in code.

Tsort problem-NZEC error

$
0
0

The OJ displays NZEC can anyone help me

import java.io.*;
import java.util.*;

public class Test {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String[] args) throws IOException {

        int array[]   = new int[10001];
        int pointer[] = {10002,-1};
        int tc = Integer.parseInt(br.readLine());

        for(int i=1;i<=tc;i++){
            int n = Integer.parseInt(br.readLine());
            array[n]++;

            pointer[0] = pointer[0] > n ? n : pointer[0];
            pointer[1] = pointer[1] < n ? n : pointer[1];
        }
        StringBuilder b = new StringBuilder("");
        for(int j=pointer[0];j<=pointer[1];j++){
            for(int i=0;i<array[j];i++){
                System.out.print(j);
            }
        }
    }
}

julka almost done, any altrnative for getch() from conio.h ??

$
0
0

i have coded correctly for julka ( http://www.spoj.com/problems/JULKA/ ) but my code depends on gecth() to make string of big no,given the fact that conio.h isnt standard and hence spoj server gives compilation error when i use getch(), is there another standard function which i can use in place of getch() or can someone tell me about the function definition of getch in conio.h here is my solution : http://ideone.com/zKJs3T thanks 4 your time..:)

NZEC ERROR in TSORT in Python 2.7

$
0
0

import sys import psyco

psyco.full()

x=int(sys.stdin.readline())

lst = [int(sys.stdin.readline()) for i in xrange(x)]

lst.sort()

print lst


Why do I get a SIGSEGV?

$
0
0

Why I am getting a runtime error SIGSEGV in the problem? Where I am going wrong?

What kind of comment should I post on the problem page?

$
0
0

Is there any comment posting guideline? I am new on this website. I have so many doubts while I participate in a contest. Can I ask them on the problem page by posting a comment? Will I be banned for asking something which is not relevant?

How to find arithmetic derivative?

use of constraints

$
0
0

i do not understand the use of constraints in my question..please help!

CodeForces - Maximum Value (484B, #276)

$
0
0

Hi guys,

I'm trying to understand the approach for Maximum Value.

Even when I read the editorial, it's not clear to me.

We have two (not necessarily distinct) number a and b from an array, such that a >= b and we want to maximize the value a % b by smartly choosing a and b.

In editorial, multiplies of b are used and I do not understand how those helps.

I'm not able to understand it also reading this neat implementation.

Of course, brute force approach is easy (so good for testing), but too slow for centest.

max = 0
for a in A
    for b in A
        if ( a > b ) max = max( max, a % b )
return max

Thanks

edit:
I found this comment, so I have think about what's said there...

How to create a shell in UNIX?

$
0
0

Hey, I need to enter a date as input and thereafter I have to tell how many files were created before that particular date in output. How am I supposed to do that involving the creation of a directory? I am absolutely new to Unix Shell Scripting.

Computer Scientist Vs Computer Programmer

$
0
0

What is difference between Computer Scientist and Computer Programmer??


Directi Coding Round Question

$
0
0

Can anyone help in finding o(n) or o(n log n) solution for this particular problem. Thanks in advance :)

Our Chef is opening a new restaurant in the city. Today being the inauguration night of his new restaurant

and Chef’s huge popularity has attracted a large crowd for the grand opening. For convenience

of the customers, cars of all the customers have been marked with a number from 0 to N-1 where N is the

total number of cars, corresponding to their parking space number in which each car has to be parked.

Due to the large crowd, the car parking is full except for one parking space. Moreover, as the cars came too frequently, they could not be parked in their respective parking space. Poor valet at the restaurant’s parking, Raka, is left with the arduous task of parking the cars at their respective places.

Luckily for him, parking has been closed and no more cars are coming and he can now arrange the cars in

their proper places. As Raka is left alone to park the cars, he can only move one car from one parking to the

other parking. He can use the empty parking space to move the cars aroung. He wants to arrange the cars in

as few moves as possible. Raka asks you for help in finding the optimal strategy to arrange cars in their proper

places.

Sample Input File:

2

3

1 0 2

4

2 1 3 0

Output:

3

4

Checking my solution

$
0
0

Is it possible to view the screen where I can see how I did in each subtask after I have closed it ?

Count of participation of each team in three asia india regionals

$
0
0

Teams which participated in one regional

Teams which participated in two regionals

Teams which participated in three regionals

Here are ACM-ICPC 2014 Asia Official Regional Rules (09/20/2014)

Under Section III -> Section A -> Point 5(c), 6(a), 7(c) are written as follows :

  • 5(c) Each University or college in Asia can organize teams to participate in the Regional contests at any Asia site. However, a contestant can participate, at most, in two (2) Asian contest sites during a contest year.

  • 6(a) The entire Asia Super-region is a tree with a root that we call it tier-1 node. Under this root node there are 18 child nodes in 2014. Each child node is an Asia Regional On-site Contest that we call tier-2 node. Under the Asia On-site contest (tier-2), we have First Round Online Sub-contest that we call it tier-3. An Asia Regional Contest Site includes both the On-site Regional contest (tier-2) and the (tier 3) First Round Online Regional Sub-Contest(s). The registration limit of two sites per year per student applies to both Asia Regional Site and their associated Online Regional Sub-contest. The tier-1 and the tier-2 two together form one Asia regional site.

  • 7(c) Repeat: A contestant can register in at most two (2) Asia Regional Sites. Each site includes the On-site contest and the first round Online sub-contest. The number of online sub-contests a contestant can participate is still limited to two (2) Asia sites.

The above rules are by C. J. Hwang, Asia Regional Contest Director.

What are the actions which will be taken against the teams participating in all three regionals?

Contest format changes in NOV Long contest

$
0
0

Please note:

  • All the problems will be partially graded and you will get score for passing certain test data (except tie-breaker problem). You will receive hundred (100) point for solving a problem (passing all test cases).
  • The details of the failed test cases will also be visible on your solution page (except challenge problem)

from contest page...

I'm wondering how this will end, let us see in 10 days...

I have no problem with partial scores, but be able to see input data during the contest, at least questionable...

edit:
I misunderstood the second point, input data are not know during the contest as far as I can see

judgement example for Nov14 Long contest

(there are no clickable links, also not in My Submissions)

How to upload partially graded problem on CodeChef

$
0
0

I wanted to add partially graded problem (subtask type/ IOI styled problems) on CodeChef. How should I do that.

Viewing all 39796 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>