CF818E.Card Game Again

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vova again tries to play some computer card game.

The rules of deck creation in this game are simple. Vova is given an existing deck of nn cards and a magic number kk . The order of the cards in the deck is fixed. Each card has a number written on it; number aia_{i} is written on the ii -th card in the deck.

After receiving the deck and the magic number, Vova removes xx (possibly x=0x=0 ) cards from the top of the deck, yy (possibly y=0y=0 ) cards from the bottom of the deck, and the rest of the deck is his new deck (Vova has to leave at least one card in the deck after removing cards). So Vova's new deck actually contains cards x+1x+1 , x+2x+2 , ... ny1n-y-1 , nyn-y from the original deck.

Vova's new deck is considered valid iff the product of all numbers written on the cards in his new deck is divisible by kk . So Vova received a deck (possibly not a valid one) and a number kk , and now he wonders, how many ways are there to choose xx and yy so the deck he will get after removing xx cards from the top and yy cards from the bottom is valid?

输入格式

The first line contains two integers nn and kk ( 1<=n<=1000001<=n<=100000 , 1<=k<=1091<=k<=10^{9} ).

The second line contains nn integers a1a_{1} , a2a_{2} , ..., ana_{n} ( 1<=ai<=1091<=a_{i}<=10^{9} ) — the numbers written on the cards.

输出格式

Print the number of ways to choose xx and yy so the resulting deck is valid.

输入输出样例

  • 输入#1

    3 4
    6 2 8
    

    输出#1

    4
    
  • 输入#2

    3 6
    9 1 14
    

    输出#2

    1
    

说明/提示

In the first example the possible values of xx and yy are:

  1. x=0,y=0x=0,y=0 ;
  2. x=1,y=0x=1,y=0 ;
  3. x=2,y=0x=2,y=0 ;
  4. x=0,y=1x=0,y=1 .
首页