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\n");
    else
        printf("Yes\n");
    return 0;
}
posted @ 2018-02-09 12:41  GoldenFingers  阅读(190)  评论(0编辑  收藏  举报