Lanzhou Sesame Cake

Source: Internet
Author: User

Lanzhou Sesame seed time limit: +Ms | Memory Limit:65535KB Difficulty:1
Describe
Sesame Cake has two sides, to do a good job of Lanzhou sesame cake, both sides are hot. Of course, you can only get one at a time, the efficiency is too low. There is such a big pan, can at the same time into the K-Lanzhou sesame cake, a minute can do a good side. And now there are n a Lanzhou sesame seed, at least how many minutes to do all the good?
Input
Enter N and K in turn, separated by spaces, where 1 <= k,n <= 100000
Output
output all do at least the required number of minutes
Sample input
3 2
Sample output
3
Tips
As a sample, three Lanzhou sesame seed number a,b,c, first A and B, then A and C, finally B and C, 3 minutes to complete

Problem Solving Ideas:

The problem compared to the pit dad is a number of test data, and the topic is not mentioned.

It is also important to note that when n>=k, it takes two minutes.

Other only need the formula (N*2)/k can

Use the three-mesh operator to

program code;

#include <stdio.h>int main () {int n,k;while (scanf ("%d%d", &n,&k)!=eof) {if (n<=k) printf ("2\n"); else{ if (((n*2)%k) ==0) printf ("%d\n", (n*2)/k); elseprintf ("%d\n", (n*2)/k+1);}} return 0;}
In addition, read the best code learned to use a statement: printf ("%d\n", ((n*2)/k==0)? (n*2)/k:(n*2)/k+1);

To replace if (((n*2)%k) ==0)
printf ("%d\n", (n*2)/k);

Else
printf ("%d\n", (n*2)/k+1);

Lanzhou Sesame Cake

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.