301443: CF271E. Three Horses

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Three Horses

题意翻译

## 【题目描述】 有灰、白、灰白相间的马各一匹。马是享受娱乐的动物,这也是为什么它们喜爱特殊的牌。每一种牌必须包含两个整数——其中一个在牌顶,一个在牌底。让我们用$(a,b)$表示顶部为$a$,底部为$b$的牌。 这三匹马都能够创造特殊的牌。 如果你把一张$(a,b)$卡牌展示给灰马,那么它就会创造一张$(a+1,b+1)$卡牌。 如果你把一张$(a,b)$卡牌展示给白马,且$a,b$都为偶数,那么它就会创造一张$(\frac{a}{2},\frac{b}{2})$卡牌。 如果你把两张分别为$(a,b),(b,c)$的卡牌展示给灰白相间的马,那么它就会创造一张$(a,c)$卡牌。 现在要求拿到$n$张特殊卡牌$(1,a_1),(1,a_2),...,(1,a_n)$。但是只能携带一张$(x,y)$前往。请问有多少种选择初始卡牌$(x,y)$的方式,能够让三匹马创造出上述所有卡牌? 只能通过上述三匹马的创造方式得到卡牌。允许用一张卡牌创造出多张。 ## 【输入格式】 第一行包含两个整数$n,m(1<=n<=10^5,2<=m<=10^9)$。 第二行包含整数序列$a_1,a_2,...,a_n(2<=a_i<=10^9)$。注意,序列中的数字可以重复。 输入中的数字被单个空格分隔开来。 ## 【输出格式】 输出一个整数——问题的答案。 在$C++$中,请不要使用$\%lld$来读取或输出$64$位整数。$cin,cout$流或者$\%l64d$更为推崇。

题目描述

There are three horses living in a horse land: one gray, one white and one gray-and-white. The horses are really amusing animals, which is why they adore special cards. Each of those cards must contain two integers, the first one on top, the second one in the bottom of the card. Let's denote a card with $ a $ on the top and $ b $ in the bottom as $ (a,b) $ . Each of the three horses can paint the special cards. If you show an $ (a,b) $ card to the gray horse, then the horse can paint a new $ (a+1,b+1) $ card. If you show an $ (a,b) $ card, such that $ a $ and $ b $ are even integers, to the white horse, then the horse can paint a new ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF271E/471d50cfa5f1fbd07876ee34ba5c335d701b8c98.png) card. If you show two cards $ (a,b) $ and $ (b,c) $ to the gray-and-white horse, then he can paint a new $ (a,c) $ card. Polycarpus really wants to get $ n $ special cards $ (1,a_{1}) $ , $ (1,a_{2}) $ , $ ... $ , $ (1,a_{n}) $ . For that he is going to the horse land. He can take exactly one $ (x,y) $ card to the horse land, such that $ 1<=x&lt;y<=m $ . How many ways are there to choose the card so that he can perform some actions in the horse land and get the required cards? Polycarpus can get cards from the horses only as a result of the actions that are described above. Polycarpus is allowed to get additional cards besides the cards that he requires.

输入输出格式

输入格式


The first line contains two integers $ n,m $ $ (1<=n<=10^{5},2<=m<=10^{9}) $ . The second line contains the sequence of integers $ a_{1},a_{2},...,a_{n} $ $ (2<=a_{i}<=10^{9}) $ . Note, that the numbers in the sequence can coincide. The numbers in the lines are separated by single spaces.

输出格式


Print a single integer — the answer to the problem. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.

输入输出样例

输入样例 #1

1 6
2

输出样例 #1

11

输入样例 #2

1 6
7

输出样例 #2

14

输入样例 #3

2 10
13 7

输出样例 #3

36

Input

题意翻译

## 【题目描述】 有灰、白、灰白相间的马各一匹。马是享受娱乐的动物,这也是为什么它们喜爱特殊的牌。每一种牌必须包含两个整数——其中一个在牌顶,一个在牌底。让我们用$(a,b)$表示顶部为$a$,底部为$b$的牌。 这三匹马都能够创造特殊的牌。 如果你把一张$(a,b)$卡牌展示给灰马,那么它就会创造一张$(a+1,b+1)$卡牌。 如果你把一张$(a,b)$卡牌展示给白马,且$a,b$都为偶数,那么它就会创造一张$(\frac{a}{2},\frac{b}{2})$卡牌。 如果你把两张分别为$(a,b),(b,c)$的卡牌展示给灰白相间的马,那么它就会创造一张$(a,c)$卡牌。 现在要求拿到$n$张特殊卡牌$(1,a_1),(1,a_2),...,(1,a_n)$。但是只能携带一张$(x,y)$前往。请问有多少种选择初始卡牌$(x,y)$的方式,能够让三匹马创造出上述所有卡牌? 只能通过上述三匹马的创造方式得到卡牌。允许用一张卡牌创造出多张。 ## 【输入格式】 第一行包含两个整数$n,m(1<=n<=10^5,2<=m<=10^9)$。 第二行包含整数序列$a_1,a_2,...,a_n(2<=a_i<=10^9)$。注意,序列中的数字可以重复。 输入中的数字被单个空格分隔开来。 ## 【输出格式】 输出一个整数——问题的答案。 在$C++$中,请不要使用$\%lld$来读取或输出$64$位整数。$cin,cout$流或者$\%l64d$更为推崇。

加入题单

算法标签: