1109:0 starting point algorithm 16--chicken rabbit with Cage

Source: Internet
Author: User

1109:0 starting point learning algorithm 16--chicken rabbit cage time limit:1 Sec Memory limit:64 MB 64bit IO Format:%lld
submitted:4456 accepted:1355
[Submit] [Status] [Web Board] Description

Chickens and rabbits in the same cage, the total number of known N and the total number of legs m, the number of chickens and the number of rabbits.

Input

Input 2 integers are N and m (multiple sets of test data)

Output

The number of chickens exported and the number of rabbits, separated by a space between, if no solution output no (each group of test data row)

Sample Input
14 32

Sample Output
12 2

Source

0 Starting point Learning algorithm

1#include <stdio.h>2 intMain () {3     intn,m;4      while(SCANF ("%d%d", &n,&m)! =EOF) {5         if((m>=2*n) && (m<=4*n) && (m%2==0))6printf"%d%d\n",2*n-m/2, m/2-n);7         Else8printf"no\n");9     }Ten     return 0; One}

Direct when!!!

1109:0 starting point algorithm 16--chicken rabbit with Cage

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.