zoukankan      html  css  js  c++  java
  • Codeforces Round #461 (Div. 2) C. Cave Painting

    C. Cave Painting

    time limit per test 1 second
    memory limit per test 256 megabytes

    Problem Description

    Imp is watching a documentary about cave painting.
    这里写图片描述
    Some numbers, carved in chaotic order, immediately attracted his attention. Imp rapidly proposed a guess that they are the remainders of division of a number n by all integers i from 1 to k. Unfortunately, there are too many integers to analyze for Imp.

    Imp wants you to check whether all these remainders are distinct. Formally, he wants to check, if all , 1 ≤ i ≤ k, are distinct, i. e. there is no such pair (i, j) that:

    1 ≤ i < j ≤ k,
    , where is the remainder of division x by y. 
    

    Input

    The only line contains two integers n, k (1 ≤ n, k ≤ 1018).

    Output

    Print “Yes”, if all the remainders are distinct, and “No” otherwise.

    You can print each letter in arbitrary case (lower or upper).

    Examples

    Input
    4 4
    Output
    No

    Input
    5 3
    Output
    Yes

    Note

    In the first sample remainders modulo 1 and 4 coincide.


    解题心得:

    1. 题意就是用n分别mod1….k,余数是否会出现重复的。
    2. 看到数据量1e18也就不可能用什么算法了。瞎搞+特判。感觉比B题还简单一些,在比赛的时候头脑昏昏的,循环倒着写(从大到小),特判贼多,第二早起来还TLE到51组,循环正着写(从小到大)不是挺好的吗,直接AC。

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    map<ll,ll> maps;
    int main() {
        ll n, m;
        scanf("%lld%lld", &n, &m);
        bool flag = false;
        ll Min = min(n-1,m);
        if(m >= n)
            Min = m;
        if(n%2 == 0 && Min >= 2)
            flag = true;
        for(ll i=1;i<=Min;i++){
            if(maps[n%i] == 1)
                flag = true;
            else
                maps[n%i] = 1;
            if(flag)
                break;
        }
        if(flag)
            printf("No
    ");
        else
            printf("Yes
    ");
        return 0;
    }
  • 相关阅读:
    Python KNN算法
    Python TF-IDF计算100份文档关键词权重
    Python 结巴分词
    Python 将pdf转换成txt(不处理图片)
    Python小爬虫-自动下载三亿文库文档
    Kubuntu麦克风音频无声音
    adb常用命令
    Ubuntu下adb的安装
    Wamp安装使用+Git for Windows
    TensorFlow使用记录 (九): 模型保存与恢复
  • 原文地址:https://www.cnblogs.com/GoldenFingers/p/9107176.html
Copyright © 2011-2022 走看看