#P2075. BePatient,ReadCarefully!

BePatient,ReadCarefully!

      Long long ago , blue blue sky piaofuing white clouds, you, Fongliqian  and  Yomean take apart int  the  GDUT Computer Programming Contest .

      Once there was a Queen. She was sitting at the window. There was snow outside in the garden-snow on the hill and in the lane, snow on the hunts and on the trees: all things were white with snow。 The Queen was making a coat for a little child. She said, "I want my child to be white as this cloth, white as the snow. And I shall call her Snow-white."

Some days after that the Queen had a child. The child was white as snow. The Queen called her Snow-white.But the Queen was very ill, and after some days she died. Snow-white lived, and was a very happy and beautiful child.

     One year after that, the King married another Queen. The new Queen was very beautiful; but she was not a good woman.A wizard had given this Queen a glass. The glass could speak. It was on the wall in the Queen's room. Every day the queen looked in the glass to see how beautiful she was. As she looked in the glass, she asked: "Tell me, glass upon the wall, who is most beautiful of all?" And the glass spoke and said: "The Queen is most beautiful of all."

     Year went by. Snow-white grew up and became a little girl. every day the Queen looked in the glass and said, "Tell me, glass upon the wall, who is most beautiful of all?" And the glass said, "Snow-white is most beautiful of all.” When the Queen heard this, she was very angry. She said, "Snow-white is not more beautiful than I am. There is no one who is more beautiful than I am."Then the Queen sat on her bed and cried.  After one hour the Queen went out of her room. She called one of the servants, and said, "Take Snow-white into the forest and kill her."

       The servant took Snow-white to the forest, but he did not kill her, because she was so beautiful and so good. He said, "I shall not kill you; but do not go to the King's house, because the Queen is angry and she will see you. If the Queen sees you, she will make some other man kill you. Wait here in the forest; some friends will help you." Then he went away.

      Poor Snow-white sat at the foot of a tree and cried. Then she saw that night was coming. She said, "I will not cry. I will find some house where I can sleep tonight. I cannot wait here: the bears will eat me."She went far into the forest. Then she saw a little hut. She opened the door of the hut, and went in. In the hut she saw seven little beds. There was a table, and on the table there were seven little loaves and seven little glasses. She ate one of the loaves. Then she said, "I want some water to drink." So she drank some water out of one of the glasses. Then she fell asleep on one of the seven little beds.

      The hut was the home of seven Little Men. When it was night, the seven Little Men came to the hut. Each Little Man had a big beard, and a little blue coat. Each Little Man came into the hut, and took his little lamp. Then each Little Man sat down, and ate his little loaf, and drank his little glass of water.

       But one Little Man said, "Someone has eaten my little loaf." And another Little Man said, "Someone has drunk my little glass of water." Then the seven Little Men went to bed, but one Little Man said, "Someone is sleeping on my little bed." All the seven Little Men came to look at Snow-white as she slept on the Little Men's bed. They said, "She is very beautiful."Snow-white awoke, and saw the seven Little Men with their big beards standing near her bed. She was afraid. The Little men said, "Do not be afraid. We are your friends. Tell us how you came here." Snow-white said, "I will tell you." Then she told them her story.


BlaBlaBla...

反正你是读不懂题目在说什么的...但是你偷偷看到了Fongliqian 的代码:

#include<stdio.h>

int main()

{

    int i,j,cnt,k,N,K,a[5555];

    scanf("%d%d",&N,&K);

    int ans=0;

    for(i=1;i<=N;i++) scanf("%d",&a[i]);

    for( i=1;i<=N;i++)

      for(j=i+1;j<=N;j++)

       {

           cnt=0;

           for( k=i;k<=j;k++) cnt+=a[k];

           if(cnt%K==0) ans++;

       }

    printf("%d\n",ans);

}


    然后你又偷偷问了Yomeam,他跟你说这样会超时(不管你信不信,反正我是信了,不信你复制粘贴上去看看?)

Input

(只有一组数据)
第一行2个整数 N K N<= 5000 K>0
第二行N个数a[i]: 第i个数为a[i] 0<= a[i]<= 10000

Output

结果,换行。

Sample Input

5 1
1 2 3 4 5

Sample Output

10

HINT

Source