日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

南邮 OJ 1128 An Industrial Spy

發布時間:2024/3/13 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 南邮 OJ 1128 An Industrial Spy 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

An Industrial Spy

時間限制(普通/Java)?:? 10000 MS/?30000 MS?? ? ? ???運行內存限制 : 65536 KByte
總提交 : 38 ? ? ? ?? ? 測試通過 : 20?

比賽描述

Industrial spying is very common for modern research labs. I am such an industrial spy { don't tell?anybody! My recent job was to steal the latest inventions from a famous math research lab. It was?hard to obtain some of their results but I got their waste out of a document shredder.

I have already reconstructed that their research topic is fast factorization. But the remaining paper?snippets only have single digits on it and I cannot imagine what they are for. Could it be that those?digits form prime numbers? Please help me to nd out how many prime numbers can be formed?using the given digits.




輸入

The rst line of the input holds the number of test cases c (1 <= c <= 200). Each test case consists of a?single line. This line contains the digits (at least one, at most seven) that are on the paper snippets.


輸出

For each test case, print one line containing the number of di erent primes that can be reconstructed?by shuing the digits. You may ignore digits while reconstructing the primes (e.g., if you get?the digits 7 and 1, you can reconstruct three primes 7, 17, and 71). Reconstructed numbers that?(regarded as strings) di er just by leading zeros, are considered identical (see the fourth case of the?sample input).


樣例輸入

4
17
1276543
9999999
011

樣例輸出

3
1336
0
2

題目來源

NWERC2009




#include<cstdio> #include<string> #include<cstring> #include<algorithm> #define MAXN 10000000 char isp[MAXN], visp[MAXN], vis[MAXN]; int a[10], t[10], sum; void init(){int i,j;isp[0]=isp[1]=1;isp[2]=isp[3]=0;for(i=4;i<MAXN;){isp[i++]=1;isp[i++]=0; //最大i==N-1,為奇數,不會越界訪問}int halfN = MAXN>>1,doubleI;for(i=3;i<=halfN;i+=2){if(!isp[i]){doubleI = i<<1;for(j=i*3;j<MAXN;j+=doubleI){isp[j]=1;}}} } int ToNum(int n){int sum = 0;for(int i = 0;i < n;i ++) sum = sum*10 + t[i];return sum; } void dfs(int n, int dep){if(dep == n){int tmp = ToNum(n);if(!isp[tmp] && !visp[tmp]){sum++;visp[tmp] = 1;}return;}for(int i = 0;i < n;i ++){if(!vis[i]){vis[i] = 1;t[dep] = a[i];dfs(n, dep+1);vis[i] = 0;}} } int main(){char str[10];int tt, b[10];init();scanf("%d", &tt);while(tt--){memset(str, 0, sizeof(str));scanf("%s", str);int len = strlen(str);for(int i = 0;i < len;i ++) b[i] = str[i]-'0';memset(visp, 0, sizeof(visp));int ans = 0;int UP = (1 << len);for(int i = 1;i < UP;i ++){int k = 0;for(int j = 0;j < len;j ++)if(i & (1 << j)) a[k++] = b[j];sum = 0;//memset(vis,0,sizeof(vis); 這句加上就超時。。。dfs(k, 0);ans += sum;}printf("%d\n", ans);}return 0; }




總結

以上是生活随笔為你收集整理的南邮 OJ 1128 An Industrial Spy的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产亚洲色婷婷久久99精品91 | 亚洲欧美自拍视频 | 久久国产精品亚洲 | 中日韩在线观看视频 | 欧美生活一级片 | 麻豆日韩| 久久青青热 | 国产日韩一区二区三免费高清 | 欧美日韩三区 | 伊人网中文字幕 | 永久免费av网站 | 国产高潮国产高潮久久久91 | 国产乱子伦视频一区二区三区 | 免费一区二区三区四区 | 超碰在线人 | 国产视频在线一区二区 | 欧美精品日韩 | 91操操操| 插吧插吧综合网 | 久久亚洲精 | 免费日本特黄 | 国产精品一区二区无线 | 午夜久久久久久久久久 | 亚洲欧美伦理 | 无套白嫩进入乌克兰美女 | 激情六月天婷婷 | 国产日韩亚洲 | 禁漫天堂黄漫画无遮挡观看 | 黑人添美女bbb添高潮了 | 亚洲大片免费看 | 欧美精品一级二级三级 | 四虎1515hh.com| 黑人超碰 | 久久成人一区二区 | 在线精品国产 | 依依成人av| 密乳av | 91九色蝌蚪91por成人 | 抽插丰满内射高潮视频 | 四季av日韩精品一区 | 欧美视频网址 | 丰满少妇大力进入 | 国产成人91| 九九在线| 性精品 | 成年人免费在线观看视频网站 | 韩国黄色网址 | 欧美三级一级片 | 污的网站 | 午夜有码 | 人妖一级片 | 国产精品无码天天爽视频 | 少妇高潮21p | 91久久久久久久久久久久久 | 国内视频精品 | 黄色裸体视频 | a天堂在线观看 | 麻豆人妻少妇精品无码专区 | 黄色在线免费 | 米奇影视第四色 | 狠狠撸在线| 激情导航 | 亚洲一区二区三区中文字幕 | 黄色片网站在线 | 欧美日韩一区电影 | 手机在线观看免费av | 男生和女生一起搞鸡 | eeuss鲁丝片一区二区三区 | 乱子伦一区二区三区 | 成人资源在线 | 日韩在线免费视频观看 | 成人wwxx免费观看 | 日日艹夜夜艹 | 里番acg★同人里番本子大全 | 欧美日韩a√ | 4438x亚洲| 国产精品美女自拍视频 | 欧美一级淫片免费视频魅影视频 | 日韩在线中文 | 在线观看亚洲av每日更新 | 中文字幕av在线 | 在线观看日批视频 | 自拍偷拍在线播放 | 国产在线精品观看 | 免费国产羞羞网站视频 | 婷婷综合久久 | 成年人午夜免费视频 | av夜夜操| 国产精品成人在线观看 | 国产免费av网 | 干老太太视频 | 操操操插插插 | 天堂网中文在线 | 欧美精品免费一区二区 | 国产一区二区三区自拍 | 亚州春色 | 久久久7777 | 日韩亚洲精品在线 | 伦伦影院午夜理伦片 |