博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #461 (Div. 2) ABC
阅读量:4595 次
发布时间:2019-06-09

本文共 3665 字,大约阅读时间需要 12 分钟。

A. Cloning Toys

Recently, he found a machine that can clone plush toys. Imp knows that if he applies the machine to an original toy, he additionally gets one more original toy and one copy, and if he applies the machine to a copied toy, he gets two additional copies.

Initially, Imp has only one original toy. He wants to know if it is possible to use machine to get exactly x copied toys and y original toys? He can't throw toys away, and he can't apply the machine to a copy if he doesn't currently have any copies.

Input

The only line contains two integers x and y (0 ≤ x, y ≤ 109) — the number of copies and the number of original toys Imp wants to get (including the initial one).

Output

Print "Yes", if the desired configuration is possible, and "No" otherwise.

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

Examples
input
Copy
6 3
output
Copy
Yes
input
Copy
4 2
output
Copy
No
input
Copy
1000 1001
output
Copy
Yes
Note

In the first example, Imp has to apply the machine twice to original toys and then twice to copies.

 

初始x = 0, y = 1,用1个y可以得到1个x和1个y,用1个x可以得到2个x,问给定的(x,y)是否可以根据给定的规则得到。

#include 
using namespace std;int main() { int x, y; cin >> x >>y; if(y==0||(y==1&&x)||x

  

B. Magic Forest

Imp is in a magic forest, where xorangles grow (wut?)

A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order n to get out of the forest.

Formally, for a given integer n you have to find the number of such triples (a, b, c), that:

  • 1 ≤ a ≤ b ≤ c ≤ n;
  • , where  denotes the  of integers x and y.
  • (a, b, c) form a non-degenerate (with strictly positive area) triangle.
Input

The only line contains a single integer n (1 ≤ n ≤ 2500).

Output

Print the number of xorangles of order n.

Examples
input
Copy
6
output
Copy
1
input
Copy
10
output
Copy
2
Note

The only xorangle in the first sample is (3, 5, 6).

 

 为是否有这样的三角形边满足i^j^k等于0,只要得到i^j  满足x [j,n]且能构成三角形即可

#include 
using namespace std;int main() { int n, ans = 0; cin >> n; for(int i = 1; i <= n; i ++) { for(int j = i; j <= n; j ++) { int x = i^j; if(x >= j && i+j > x && x <= n) ans++; } } cout << ans<

  

C. Cave Painting

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 nk (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
Copy
4 4
output
Copy
No
input
Copy
5 3
output
Copy
Yes
Note

In the first sample remainders modulo 1 and 4 coincide.

 

 给定n,k。求n%1,n%2...n%k  是否是k个不同的数,是就是yes,否则就是no。

n%1 = 0,n%2 = (0|1)

由于n%1=0,所以n%2一定要等于1才行,n%3=(0|1|2) 所以一定要等于2

即n%i = i-1才行,有一个不成立就是No

#include 
using namespace std;#define ll long longint main() { ll n, k; cin >> n >> k; bool flag = true; for(ll i = 1; i <= k; i ++) { if(n%i != i-1) { flag = false; break; } } if(flag) printf("Yes\n"); else printf("No\n"); return 0;}

  

转载于:https://www.cnblogs.com/xingkongyihao/p/8819268.html

你可能感兴趣的文章
linux ssh搭建
查看>>
elasticsearch 7 安装
查看>>
Java实现打印功能
查看>>
Centos使用LVS+keepalive 搭建集群原理详解
查看>>
Objective-C 的三种 Callbacks 机制
查看>>
11.07 scrum report
查看>>
CentOS7静态IP设置
查看>>
java ee开发杂记
查看>>
php小程序支付代码(微信公众平台,完整版)
查看>>
nginx 使用总结
查看>>
贝多芬《升c小调第十四钢琴奏鸣曲》 个人浅谈
查看>>
了解一些多线程相关的知识
查看>>
C#入门详解(11)
查看>>
JQuery的ajax的用法 在asp中使用 $.ajax()
查看>>
LeetCode15——3Sum
查看>>
简洁版三级菜单
查看>>
Python基础知识练习题(二)
查看>>
[NOI2008]假面舞会(DFS)
查看>>
BZOJ2137: submultiple(生成函数,二项式定理)
查看>>
winform程序关闭界面时弹出提示框
查看>>