zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 13 A. Johny Likes Numbers

    题目传送

    题目分析

    题意:给两个数字(n)(k),让你在(k)的倍数中,找出大于(n)的最小数字(x),即(n>x)

    这道题很裸也很简单,答案就是(k imes (lfloor frac{n}{k} floor +1))这个动动脑子就能想明白

    这里鄙人自己个给出了一个不太严谨的数学证明:

    [ ext{设存在两个正整数A、B,其中}A>B \ ext{设存在正整数}n,使得A<n imes B恒成立,即n>frac{A}{B} \ 已知exists sigma in [0,1),lfloor frac{A}{B} floor +sigma=frac{A}{B}\ 则lfloor frac{A}{B} floor+1>lfloor frac{A}{B} floor +sigma=frac{A}{B} \ 故存在n=lfloor frac{A}{B} floor+1使得n>frac{A}{B}恒成立 ]

    这里在留下一个简单的问题:如果这道题让你求(nge x)呢?

    AC代码

    #include <bits/stdc++.h>
    #define io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
    #define rT printf("
    Time used = %.3lf
    ", (double)clock()/CLOCKS_PER_SEC)
    
    using namespace std;
    typedef long long ll;
    ll n, k;
    
    int main() {
        io;
        cin >> n >> k;
        cout << k * (n / k + 1) << '
    ';
        
        return 0;
    }
    

    上述问题答案:(k imes lceil frac{n}{k} ceil),代码实现略

  • 相关阅读:
    关于LockSupport
    Sqrtx
    Text Justification
    Unique Paths II
    N-Queens
    Anagrams
    CSipSimple通话记录分组
    CSipSimple配置系统
    Permutations II 再分析
    CSipSimple的插件结构
  • 原文地址:https://www.cnblogs.com/FrankOu/p/14608771.html
Copyright © 2011-2022 走看看