CF861B Which floor?
2024-08-30 22:44:02
思路:
暴力枚举。
实现:
#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 ;
}
最新文章
- pickle 序列化反序列化
- android 代码优化
- Android Immersive Mode (沉浸模式) 还是 Translucent Bars (透明状态栏)
- 使用SQLite数据库和Access数据库的一些经验总结
- 《ASP.NET1200例》解决母版页报错“内容控件必须是内容页中的顶级控件,或是引用母版页的嵌套母版页。”
- stdlib
- android 中动画
- javascript - 工作笔记 (事件绑定二)
- 用Python实现gmail邮箱服务,实现两个邮箱之间的绑定(下)
- 基于Elastalert的安全告警剖析
- unigui+fastreport报表打印
- google 身份验证器
- Java java.lang.SecurityException: Prohibited package name
- IPhone手机页面中点击文本输入框,弹出键盘,网页会放大,如何解决
- 20145334赵文豪 WEB基础实践
- Spring的模块组成
- 【转】BMR(Block Media Recovery)
- Netty概述
- UVA 10886 Standard Deviation
- C++(十九) — const 和 #define 区别