国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

sdutacm-迷之好奇

2019-11-06 06:21:04
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

迷之好奇

TimeLimit: 2000MS Memory Limit: 65536KB

SubmitStatistic

PRoblem Description

FF得到了一個(gè)有n個(gè)數(shù)字的集合。不要問(wèn)我為什么,有錢(qián),任性。

FF很好奇的想知道,對(duì)于數(shù)字x,集合中有多少個(gè)數(shù)字可以在x前面添加任意數(shù)字得到。

如,x = 123,則在x前面添加數(shù)字可以得到4123,5123等。

Input

 多組輸入。

對(duì)于每組數(shù)據(jù)

首先輸入n(1<= n <= 100000)。

接下來(lái)n行。每行一個(gè)數(shù)字y(1 <= y<= 100000)代表集合中的元素。

接下來(lái)一行輸入m(1 <= m <= 100000),代表有m次詢(xún)問(wèn)。

接下來(lái)的m行。

每行一個(gè)正整數(shù)x(1 <= x <= 100000)。

Output

 對(duì)于每組數(shù)據(jù),輸出一個(gè)數(shù)字代表答案。

Example Input

3

12345

66666

12356

3

45

12345

356

Example Output

1

0

1

Hint

 

Author

 zmx

#include <stdio.h>  #include <string.h>  int top;  struct node  {      int next[26];      int flag;  } st[5001000];  int creat()  {      memset(st[top].next,-1,sizeof(st[top].next));      st[top].flag=0;      return top++;  }  void insertt(int root,char*s)  {      int len=strlen(s);      for(int i=len-1; i>=0; i--)      {          int t=s[i]-'0';          if(st[root].next[t]==-1)          {              st[root].next[t]=creat();          }          st[root].flag++;          root=st[root].next[t];      }  }  int cmp(char *s,int root)  {      int len=strlen(s);      for(int i=len-1; i>=0; i--)      {          int  t=s[i]-'0';          if(st[root].next[t]==-1)          {              return 0;          }          root=st[root].next[t];      }      return st[root].flag;  }  int main()  {      int n,m,root;      char s[101];      char s1[101];      while(~scanf("%d",&n))      {          top=0;          root=creat();          while(n--)          {              scanf("%s",s);              insertt(root,s);          }          scanf("%d",&m);          while(m--)          {              scanf("%s",s1);              printf("%d/n",cmp(s1,root));          }      }      return 0;  } /***************************************************User name: jk160505徐紅博Result: AcceptedTake time: 388msTake Memory: 1396KBSubmit time: 2017-02-10 16:44:15****************************************************/

 


發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 姚安县| 西充县| 安岳县| 武山县| 静宁县| 泗阳县| 罗甸县| 三江| 永嘉县| 安吉县| 台湾省| 盐津县| 富川| 双牌县| 乌拉特后旗| 广西| 阿拉尔市| 临泽县| 新乡县| 诏安县| 宜兰县| 肇庆市| 赞皇县| 来安县| 绥宁县| 临漳县| 金阳县| 西吉县| 河东区| 彭阳县| 鄢陵县| 松溪县| 同仁县| 梁平县| 东辽县| 河北省| 通州市| 确山县| 红原县| 仲巴县| 湟中县|