B. Filya and Homework】的更多相关文章

B. Filya and Homework 题目连接: http://codeforces.com/contest/714/problem/B Description Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help. Filya is given an arra…
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your hel…
题目链接:http://codeforces.com/problemset/problem/714/B 题目大意: 第一行输入一个n,第二行输入n个数,求是否能找出一个数x,使得n个数中的部分数加上x或部分数减去x ,n个数相等. 例如:5 1 3 3 2 1 输出: YES Init: x=1 情况,第一个数和最后一个数+x,第二三个数减去x ,则这n个数都为2(相等),故输出“YES” 解题思路: 对于刚才举的例子 可知 n个数只有三个元素 1 2 3 只要使得 2-1==3-2 即可满足条…
题目链接:http://codeforces.com/problemset/problem/714/B 题意: 给你一个含有 n 个数的数组, 问你是否存在一个 x, 使得这个数组中的某些数加上 x, 某些数减去 x 后所有数都相等. 思路: 如果这个数组里面不相等的数大于 3 个那么 x 就不可能存在. 否则如果这个数组里仅有三个数不一样且设为 a, b, c(a < b < c), 则还必须满足 b - a == c - b. 使得所有等于 a 的数加上 b - a 变为 b, 所有等于…
http://codeforces.com/contest/714/problem/B 给定一个序列,对于每一个元素,只能 + 或者 - 一个数val.这个数一旦选定,就不能改. 问能否变成全部数字都一样. 一开始还以为没 + 一次,就要 - 一次. 结果不是,一直wa 那么这样的话,这题的正解是观察法.也可以证明. ①.全部数字都一样.有两个不同数字.三个不同数字(a[1] + a[3] =  2 * a[2])这些都易懂 那4个不同数字为什么是no呢 可以想象成找不到一个点,作为圆心,包含另…
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Fr…
Filya and Homework 题意: 给定一串数字,任选一个数a,把若干个数加上a,把若干个数减去a,能否使得数列全部相同: 思路: 我开始就想找出平均数,以为只有和偶数的可以,结果wa在 1, 3这样的数据上: 后来才知道是要考虑等差数列的判定(还只用考虑3个的情况),下面还学到了大佬的骚操作: 正确解法:如果这个数组里面不相等的数大于 3 个那么 x 就不可能存在. 否则如果这个数组里仅有三个数不一样且设为 a, b, c(a < b < c), 则还必须满足 b - a == c…
Codeforces Round #371 (Div. 2) A. Meeting of Old Friends |B. Filya and Homework A. Meeting of Old Friends  模拟 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; typedef long long ll;…
B. Filya and Homework time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to com…
A. Meeting of Old Friends time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya! Sony…