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.
解题心得:
- 题意就是用n分别mod1….k,余数是否会出现重复的。
- 看到数据量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;
}
Codeforces Round #461 (Div. 2) C. Cave Painting的更多相关文章
- CF922 CodeForces Round #461(Div.2)
CF922 CodeForces Round #461(Div.2) 这场比赛很晚呀 果断滚去睡了 现在来做一下 A CF922 A 翻译: 一开始有一个初始版本的玩具 每次有两种操作: 放一个初始版 ...
- Codeforces Round #461 (Div. 2) B C D
题目链接:http://codeforces.com/contest/922 B. Magic Forest time limit per test 1 second memory limit per ...
- Codeforces Round #461 (Div. 2)
A - Cloning Toys /* 题目大意:给出两种机器,一种能将一种原件copy出额外一种原件和一个附件, 另一种可以把一种附件copy出额外两种附件,给你一个原件, 问能否恰好变出题目要求数 ...
- Codeforces Round #353 (Div. 2) B. Restoring Painting 水题
B. Restoring Painting 题目连接: http://www.codeforces.com/contest/675/problem/B Description Vasya works ...
- Codeforces Round #599 (Div. 1) A. Tile Painting 数论
C. Tile Painting Ujan has been lazy lately, but now has decided to bring his yard to good shape. Fir ...
- Codeforces Round #461 (Div. 2) D. Robot Vacuum Cleaner
D. Robot Vacuum Cleaner time limit per test 1 second memory limit per test 256 megabytes Problem Des ...
- Codeforces Round #461 (Div. 2) B. Magic Forest
B. Magic Forest time limit per test 1 second memory limit per test 256 megabytes Problem Description ...
- Codeforces Round #461 (Div. 2) A. Cloning Toys
A. Cloning Toys time limit per test 1 second memory limit per test 256 megabytes Problem Description ...
- Codeforces Round #461 (Div. 2)B-Magic Forest+位运算或优雅的暴力
Magic Forest 题意:就是在1 ~ n中找三个值,满足三角形的要求,同时三个数的异或运算还要为0: , where denotes the bitwise xor of integers ...
随机推荐
- 框架使用-Sql拼接
Sql语句拼写: 查询 DQueryDom DmoQuery(返回的整个对象) 更新 DQUpdateDom 删除 DQDeleteDom 条件 dom.Where.Conditions.Add(D ...
- pycharm 更改字体and背景颜色
File-settings-Appearance&Behavior-Appearance-Theme File-settings-Editor-font
- JAVA反射练习
JAVA反射练习 题目 实现一个方法 public static Object execute(String className, String methodName, Object args[]) ...
- chart.js 使用方法 特别说明不是中文的
以上是一个饼图的案例,其他统计类型查看文档 http://www.chartjs.org/docs/latest/charts/doughnut.html 注意看域名 chartjs.org 不是 ...
- IOS微信6.7.4输入框失去焦点,软键盘关闭后,被撑起的页面无法回退到原来正常的位置
近期在开发微信H5页面时碰到这个问题,如图,软键盘弹起后,若原输入框被遮挡,页面整体将会上移,然而当输入框失焦,软键盘收起后,页面未恢复,这也是ios的微信版本更新6.7.4之后才遇到的bug. 目前 ...
- ORACLE 数据库的级联查询 一句sql搞定(部门多级)
在ORACLE 数据库中有一种方法可以实现级联查询 select * //要查询的字段 from table //具有子接点ID与父接点I ...
- js对jsonArray的操作
上一篇写了关于java中Gson对jsonArray的排序处理,这里介绍js中对jsonArray处理, <!DOCTYPE html> <html> <head> ...
- mongodb 认证方式(version:3.0.4)
之前一直在本机上跑,前段时间把后台架到云服务器上了,在settings里加上了username和password,希望同步的时候修改一下settings就能在本地测试. 因为云服务器端数据库连接需 ...
- static int a
static int a只被本文件可见,外部文件不可见;而int a如果在外部文件作以下声明: extern int a,那么它在声明的文件里也是可见的 详见:http://bbs.csdn.net/ ...
- [习题] FindControl 简单练习--GridView + CheckBox,点选多列数据(复选删除)#3 List或数组
[习题] FindControl 简单练习--GridView + CheckBox,点选多列数据(复选删除)#3 List或数组 之前的范例,使用字符串.文字来记录将删除的文章ID 后续会有很多小缺 ...