A828 | I Would Walk 500 Miles--Gold
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Farmer John wants to divide his $N$ cows $(N \leq 7500)$, conveniently
numbered $1 \ldots N$, into $K$ non-empty groups ($2 \leq K \leq N$) such that
no two cows from two different groups can interact with each other without
walking some number of miles. Cow $x$ and Cow $y$ (where $1 \leq x < y \leq
N$) are willing to walk $(2019201913x + 2019201949y)\text{ mod } 2019201997$
miles to see each other.
Given a division of the $N$ cows into $K$ non-empty groups, let $M$ be the
minimum of the number of miles any two cows in two different groups are
willing to walk to see each other. To test the cows' devotion to each other,
Farmer John wants to optimally divide the $N$ cows into $K$ groups such that
$M$ is as large as possible. The memory limit for this problem is set to
512MB, above the usual 256MB limit.
numbered $1 \ldots N$, into $K$ non-empty groups ($2 \leq K \leq N$) such that
no two cows from two different groups can interact with each other without
walking some number of miles. Cow $x$ and Cow $y$ (where $1 \leq x < y \leq
N$) are willing to walk $(2019201913x + 2019201949y)\text{ mod } 2019201997$
miles to see each other.
Given a division of the $N$ cows into $K$ non-empty groups, let $M$ be the
minimum of the number of miles any two cows in two different groups are
willing to walk to see each other. To test the cows' devotion to each other,
Farmer John wants to optimally divide the $N$ cows into $K$ groups such that
$M$ is as large as possible. The memory limit for this problem is set to
512MB, above the usual 256MB limit.
输入格式
The input is just one line, containing $N$ and $K$, separated by a space.
输出格式
Print out $M$ in an optimal solution.
输入输出样例
输入 #1
3 2
输出 #1
2019201769
In this example, Cow 1 and Cow 2 are willing to walk 2019201817 miles to see
each other. Cow 2 and Cow 3 are willing to walk 2019201685 miles. And Cow 1
and Cow 3 are willing to walk 2019201769 miles. Thus, by grouping the cows
such that 1 is by herself and 2 and 3 are grouped together, $M =
\min(2019201817,2019201769) = 2019201769$ (which is the best we can do here).
each other. Cow 2 and Cow 3 are willing to walk 2019201685 miles. And Cow 1
and Cow 3 are willing to walk 2019201769 miles. Thus, by grouping the cows
such that 1 is by herself and 2 and 3 are grouped together, $M =
\min(2019201817,2019201769) = 2019201769$ (which is the best we can do here).
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted