1057: Counterfeit Currency

Source: Internet
Author: User

1057: Counterfeit Currency

Time limit (Common/Java): 1000 MS/10000 MS  Running memory limit: 65536 KByte
Total submissions: 2844
    Tested: 773

Description

There are counterfeit coins !!!
This is the case. Now, pork has risen, but the wages of farmers have not risen. How can I buy pork if I have no money. Yuan Zi went here to buy pork. As a result, there were counterfeit coins in the change !!! Unfortunately, yuanzi accidentally mixed it into a pile of real coins. We now know that counterfeit coins are lighter than real coins. Give you a balance. Please use the fastest time to find out the hateful counterfeit currency.

Input

1 ≤ n ≤ 230, input 0 to end the program.

Output

The counterfeit currency can be found at least several times.

Sample Input

3

12

0

Sample output

1

3

Prompt

In example 1, there are three coins in total, so take any two coins and weigh them on the balance.
Because the counterfeit currency is light in weight.

    • If the balance is not balanced, the lighter one is the counterfeit currency.
    • If the balance is balanced, the two coins are true, and the remaining one is a counterfeit coin.

The optimal features of the problem are divided into three heaps.

 

#include <stdio.h><math.h> f(( ==         ( ==         ( ==         (x == (pow(, ()( log (x) / log ( (log (x) / log (         ( + ()(log (x) / log (

 

    

#include <stdio.h>(scanf(, &n), n !=  count = (n != ( ==                ( ==+=                 ( ==+= (n % ) :    n /= ; :    n = (n + ) / ; : n = (n + ) / ;++ 

 

Add a function

Function Name: ceil

Usage: double ceil (double x );

Function: returns the smallest integer greater than or equal to the specified expression.

Header file: math. h

Chinese name

Ceil

UseMethod

Double ceil

MeritYes

Returns the smallest integer greater than or equal to the expression.

Header file

Math. h

Simplification of the first solution

   

#include<stdio.h><math.h>    (scanf(,&n),n != ,ceil(log(n)/log()));     }

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.