思路:

暴力枚举。

实现:

 #include <bits/stdc++.h>
using namespace std;
int n, m, x, y;
bool check(int x, unordered_map<int, int>& m)
{
for (auto it : m)
{
int a = it.first, b = it.second;
if ((a + x - ) / x != b) return false;
}
return true;
}
int main()
{
while (cin >> n >> m)
{
unordered_map<int, int> mp;
for (int i = ; i < m; i++)
{
cin >> x >> y;
mp[x] = y;
}
int ans = -;
bool flg = true;
for (int i = ; i <= ; i++)
{
if (check(i, mp))
{
if (ans != - && (n + i - ) / i != ans)
{
flg = false; break;
}
else ans = (n + i - ) / i;
}
}
if (flg && ans != -) cout << ans << endl;
else cout << - << endl;
}
return ;
}

最新文章

  1. pickle 序列化反序列化
  2. android 代码优化
  3. Android Immersive Mode (沉浸模式) 还是 Translucent Bars (透明状态栏)
  4. 使用SQLite数据库和Access数据库的一些经验总结
  5. 《ASP.NET1200例》解决母版页报错“内容控件必须是内容页中的顶级控件,或是引用母版页的嵌套母版页。”
  6. stdlib
  7. android 中动画
  8. javascript - 工作笔记 (事件绑定二)
  9. 用Python实现gmail邮箱服务,实现两个邮箱之间的绑定(下)
  10. 基于Elastalert的安全告警剖析
  11. unigui+fastreport报表打印
  12. google 身份验证器
  13. Java java.lang.SecurityException: Prohibited package name
  14. IPhone手机页面中点击文本输入框,弹出键盘,网页会放大,如何解决
  15. 20145334赵文豪 WEB基础实践
  16. Spring的模块组成
  17. 【转】BMR(Block Media Recovery)
  18. Netty概述
  19. UVA 10886 Standard Deviation
  20. C++(十九) — const 和 #define 区别

热门文章

  1. JDBC的数据类型
  2. 剑指Offer - 两个链表第一个公共节点
  3. vi,vim的基本使用方法
  4. 走进Struts2(一) — Struts2的执行流程及其工作原理
  5. 删除子节点XML数据
  6. J2SE基础:11.异常处理
  7. JavaScript基础 -- BOM
  8. grep 并列查询 效率 且 或
  9. JavaScript总结01
  10. YTU 2507: 李白打酒