2017 Guangdong University of Technology Program design Competition final-two Tigers __ violence

Source: Internet
Author: User

Two Tigers Description

Come, let's relax, listen to the nursery rhymes, and "sing" together.

Two tigers, two tigers, run fast.

One has no ears and one has no tail.

It's strange, it's strange.

TMK also felt very strange, because in front of him suddenly appeared a group of such tigers, some have no ears, some have no tail, but there are normal.

Now TMK tells you the number of ears, the number of tails, and the number of legs of the tiger, and how much it is normal to ask you.

There are only three species of tigers:

The first (normal): 2 ears, 1 tails, 4 legs

Second (no ears): 0 ears, 1 tails, 4 legs

Third (no tail): 2 ears, 0 tails, 4 leg Input

The first line of an integer t indicates how many groups of samples there are.

Next each row is a sample:

Contains three integers a,b,c indicates a total of a ear, B tail, C (<=4000) leg, the data guaranteed to have the solution. Output

For each set of sample output lines, the number of normal tigers is indicated. Sample Input 112 7 Sample Output 3 HINT

The idea of solving problems: violence

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <climits>
  
using namespace std;
  
#define LL Long
const int inf=0x3f3f3f3f;
  
int main ()
{
    int t,a,b,c;
    scanf ("%d", &t);
    while (t--)
    {
        scanf ("%d%d%d", &a,&b,&c);
        c/=4;
        for (int i=0; i<=1000; i++)
        {for
            (int j=0; j<=1000; j + +)
            {
                if i*2+ (c-i-j) *2==a&&i+j ==b)
                {
                    printf ("%d\n", I);
                    Break
    ;
    }}} return 0;
}

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.