zoukankan      html  css  js  c++  java
  • codeforce 606A

    题意:a,b,c三种球,能把俩个一样的球变成另一颜色不一样的球。给你目标x,y,z,问能否经过变化至少达打目标。

     1 #include<iostream>
     2 #include<stdio.h>
     3 #include<stdlib.h>
     4 #include<memory.h>
     5 #include<string.h>
     6 #include<algorithm>
     7 #include<cmath>
     8 const int N = 30;
     9 const int inf=-100000;
    10 using namespace std;
    11 int ans;
    12 void fun(int x)
    13 {
    14     if(x>=0)
    15     {
    16         ans+=x/2;
    17     }
    18     else
    19     {
    20         ans+=x;
    21     }
    22 }
    23 
    24 int main()
    25 {
    26     int a[3];
    27     int b[3];
    28     while(~scanf("%d%d%d",&a[0],&a[1],&a[2]))
    29     {
    30         scanf("%d%d%d",&b[0],&b[1],&b[2]);
    31         ans=0;
    32         fun(a[0]-b[0]);
    33         //cout<<ans<<endl;
    34         fun(a[1]-b[1]);
    35         //cout<<ans<<endl;
    36         fun(a[2]-b[2]);
    37         //cout<<ans<<endl;
    38         if(ans>=0)
    39         {
    40             cout<<"Yes"<<endl;
    41         }
    42         else
    43         {
    44             cout<<"No"<<endl;
    45         }
    46     }
    47     return 0;
    48 }
    View Code
  • 相关阅读:
    构造函数作为友元函数的参数
    引用调用
    分块查找
    折半查找
    c++中map按key和value排序
    STL之map学习实例
    STL之stack
    STL之map
    STL之string
    STL之template类模板
  • 原文地址:https://www.cnblogs.com/ITUPC/p/5035618.html
Copyright © 2011-2022 走看看