2020 GDUT Rating Contest II (Div. 2) H. I Would Walk 500 Miles

来源:codeforces 2020 GDUT Rating Contest II (Div. 2) CF链接

题目:
Farmer John wants to divide his N cows (N≤7500), conveniently numbered 1…N, into K non-empty groups (2≤K≤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≤x<y≤N) are willing to walk (2019201913x+2019201949y) 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.

Input
The input is just one line, containing N and K, separated by a space.

Output
Print out M in an optimal solution.

Example
input
3 2
output
2019201769

题意:将n头牛分成k组,使得用指定方法计算出的任意两头不同组的奶牛的最小距离最大。距离计算方法为d=(2019201913x+2019201949y) mod 2019201997,x、y为两头奶牛的坐标(理解为在数轴上)
思路:一开始直接把1和n带入x和y,结果居然能过7个点,然后发现这个距离出现在最后一头牛和倒数第二组的最后一头牛,于是把前k-1头牛分为k-1组,剩下的为第k组,就得到答案。

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<queue>
#define INF 0x3f3f3f3f
#define mod 2019201997
using namespace std;

int n,k;
int main()
{
	cin>>n>>k;
	long long ans=(1ll*2019201913*(k-1)+1ll*2019201949*n)%2019201997;
	cout<<ans;
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值