http://community.topcoder.com/stat?c=problem_statement&pm=12975

简单题

#include <cstdlib>
#include <vector>
using namespace std; class EllysNumberGuessing {
public:
int getNumber(vector <int> guesses, vector <int> answers) {
const int LIMIT = 1000000000;
int N = guesses.size();
int res = -2; // not find
vector<int> options{ guesses[0] + answers[0], guesses[0] - answers[0]};
for (int i = 0; i < options.size(); i++) {
int x = options[i];
bool valid = (x >= 1 && x <= LIMIT);
for (int j = 1; j < N; j++) {
valid = valid && (abs(guesses[j] - x) == answers[j]);
}
if (valid) {
if (res == -2) {
res = x;
} else {
res = -1;
}
}
}
return res;
} };

  

最新文章

  1. Cache-Aside Pattern(缓存模式)
  2. Windows Phone App的dump文件实例分析- System.ExecutionEngineException
  3. 各种Linux发行版本优缺点对比[转]
  4. js部分---数组及练习题;
  5. http://www.cnblogs.com/flyoung2008/archive/2013/08/11/3251148.html
  6. 8天学通MongoDB——第八天 驱动实践
  7. Sigar.jar获取系统信息
  8. oracle 使用sql获取数据库表,表的字段
  9. java 笔试
  10. [编织消息框架][设计协议]bit基础
  11. Hadoop2.7.5+Hbase1.4.0完全分布式
  12. 如何设置select和option的文字居中?
  13. python数据类型:字典dict常用操作
  14. springboot application.properties 常用完整版配置信息
  15. softmax 损失函数求导过程
  16. Codeforces962F Simple Cycles Edges 【双连通分量】【dfs树】
  17. canutils上板测试问题记录
  18. 源码安装 odoo12 -- 问题记录
  19. spring与activemq(三种消息监听方式)
  20. ROS 进阶学习笔记(12) - Communication with ROS through USART Serial Port

热门文章

  1. wpf窗体中复合控件焦点控制
  2. apache泛域名的配置
  3. Firebird数据库相关备忘录
  4. Global::validateEmail
  5. django - transaction
  6. Spark 大数据平台
  7. Python实战(1)
  8. Java 基础学习1 -- 基础语法
  9. LintCode-Implement Iterator of Binary Search Tree
  10. OC特有语法:分类category,给NSString增加方法计算字符串中数字的个数