codeforce 606A - Magic Spheres

题意: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 }

时间: 2024-08-11 09:56:25

codeforce 606A - Magic Spheres的相关文章

CodeForce 424C Magic Formulas

这个题就是求出给的公式的结果. 只要知道异或运算满足交换律跟结合律就行了,之后就是化简公式. #include<map> #include<string> #include<cstring> #include<cstdio> #include<cstdlib> #include<cmath> #include<queue> #include<vector> #include<iostream> #i

Codeforces Round #335 (Div. 2)

水 A - Magic Spheres 这题也卡了很久很久,关键是“至少”,所以只要判断多出来的是否比需要的多就行了. #include <bits/stdc++.h> using namespace std; #define lson l, mid, o << 1 #define rson mid + 1, r, o << 1 | 1 typedef long long ll; const int N = 1e5 + 5; const int INF = 0x3f3f

HDU 4421 Bit Magic(2-sat)

HDU 4421 Bit Magic 题目链接 题意:就依据题目,给定b数组.看能不能构造出一个符合的a数组 思路:把每一个数字的每一个二进制位单独考虑.就变成一个2-sat题目了,依据题目中的式子建立2-sat的边.然后每一位跑2-sat.假设每位都符合.就是YES,假设有一位不符合就是NO 代码: #include <cstdio> #include <cstring> #include <cstdlib> #include <vector> #incl

php中的魔术方法(Magic methods)和魔术常亮

PHP中把以两个下划线__开头的方法称为魔术方法,这些方法在PHP中充当了举足轻重的作用. 魔术方法包括: __construct(),类的构造函数 __destruct(),类的析构函数 __call(),在对象中调用一个不可访问方法时调用 __callStatic(),用静态方式中调用一个不可访问方法时调用 __get(),获得一个类的成员变量时调用 __set(),设置一个类的成员变量时调用 __isset(),当对不可访问属性调用isset()或empty()时调用 __unset(),

magic number介绍

magic number:魔数,这是放在linux的目录中的文件信息块中的一个标识符,一般只有几位,用来标识该文件是什么类型的文件,可以被什么样的应用使用.这个魔数不是固定的,有时候一个文件信息中的魔数可能会不断变化.这个东西不重要的,对用户造不成多少影响.两个例子:1.ELF文件的头部,前4个字节是魔数.这个常用于识别文件类型等.linux上,二进制的可执行文件的前四个字节是7f45,而在AIX上,二进制可执行文件的前四个字节是0x01df.2.内核程序中,给一些 IO 操作进行编号时,也会用

CES聚焦:荣耀Magic凭什么成最闪耀的星

就在美国科技博客TechCrunch以<要是这款高颜值高智慧的荣耀Magic能来美国就好了>为题的评论发布不到半个月,荣耀就借刚刚于拉斯维加斯召开的CES国际消费电子展的契机,将这款很"Magic"的产品带出国门,推向了全球市场.这款曾在国内引发广泛争议的焦点产品,凭借着手机端人工智能的开拓性创新,在素有"科技风向标"和"潮流科技博览会"美誉的CES上备受关注,甚至于有好事者将之称为"2016~2017手机界最闪耀的一颗星&

codeforces 710C C. Magic Odd Square(构造)

题目链接: C. Magic Odd Square Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd. Input The only line contains odd integer n (1 ≤ n ≤ 49). Output Print n lines with n integers. All the

ZOJ 3622 Magic Number(数)

题意  假设一个正整数y满足  将随意正整数x放到y的左边得到的数z满足 z%y==0  那么这个数就是个Magic Number   给你一个范围  求这个范围内Magic Number的个数 令 l表示y的位数  ly=10^l  那么z=x*ly + y  要z%y==0   easy看出  仅仅需 x*ly%y==0 又由于x是随意的  所以一个Magic Number必须满足 ly%y==0 y<2^31  所以l最大为10 直接枚举l  找到全部符合的y即可了 当 ly%y==0  

1037. Magic Coupon (25)

题目例如以下: The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product back! What is more, the shop also offers so