CF-Educational Codeforces Round 103 (Rated for Div. 2)-A. K-divisible Sum【思维】

题目链接
题意:要求构造一个 n n n个正整数数的集合,使得其和能够整除 k k k,同时使得集合中的最大值最小,求这个最大值的最小值。
思路:明显尽量均分是最佳方案,注意 n > k n>k n>k时由于集合中元素必须是正整数,可以对 k k k进行整数倍放大来处理。
AC代码:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}

const double eps=1e-9;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn = 1e5 + 10;
const int MAX = 1e5;
const double pi = acos(-1.0);
const ll INF = 0x3f3f3f3f3f3f3f;
ll qpow(ll a, ll b) {
    ll res = 1;
    while (b) {if (b & 1) res = (res * a) % mod;a = (a * a) % mod;b >>= 1;}
    return res % mod;
}
/***************main****************/
ll T=1;
ll m,n;
int main() {
    T=read();
    while (T--) {
        ll k;
        cin>>n>>k;
        if(n>k) k=((n-1)/k+1)*k;
        ll ans=ceil((double)k/(double)n);
        cout<<ans<<endl;
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值