模擬

狀態壓縮?

uva?12368?-?Candles? ?2011 - Dhaka

 1 #include<stdio.h>
2 #include<string.h>
3 #include<iostream>
4 #include<string>
5 #include<algorithm>
6 #include<math.h>
7 #include<map>
8 #include<queue>
9 using namespace std;
10 #define LL long long
11 #define nMAX (1<<10+10)
12 #define mMAX 110
13 int ar[25],n;
14 int f[nMAX];
15 bool vis[nMAX][mMAX];
16 struct node{
17 int a,b,num;
18 };
19 void init(){
20 int a[100]; node b[100];
21 for(int x=0;x<(1<<10);x++){
22 int cnta=0,cntb=0;
23 for(int i=0;i<10;i++) if(x&(1<<i)){
24 a[cnta++]=i; vis[x][i]=true;
25 }
26 for(int i=0;i<cnta;i++) for(int j=0;j<cnta;j++) if(i!=j) {
27 int num=a[i]*10+a[j];
28 b[cntb].a=i, b[cntb].b=j, b[cntb++].num=num;
29 vis[x][num]=true;
30 }
31 for(int i=0;i<cnta;i++) for(int j=0;j<cnta;j++) if(i!=j){
32 int num=a[i]+a[j];
33 if(num<=100) vis[x][num]=true;
34 }
35 for(int i=0;i<cnta;i++) for(int j=0;j<cntb;j++) if(i!=b[j].a&&i!=b[j].b){
36 int num=a[i]+b[j].num;
37 if(num<=100) vis[x][num]=true;
38 }
39 for(int i=0;i<cntb;i++) for(int j=0;j<cntb;j++)
40 if(b[i].a!=b[j].a&&b[i].a!=b[j].b
41 &&b[i].b!=b[j].a&&b[i].b!=b[j].b){
42 int num=b[i].num+b[j].num;
43 if(num<=100) vis[x][num]=true;
44 }
45 }
46 }
47 bool ok(int x){
48 for(int i=0;i<n;i++) if(!vis[x][ar[i]]) return false;
49 return true;
50 }
51 int number(int x){
52 int sum=0, p=1;
53 for(int i=0;i<10;i++) if((1<<i)&x) {
54 sum+=i*p; p*=10;
55 }
56 return sum;
57 }
58 int main(){
59 int T=1; init();
60 for(int i=0;i<(1<<10);i++)
61 for(int j=0;j<10;j++) if(i&(1<<j)) f[i]++;
62 f[nMAX-1]=111;
63
64 while(scanf("%d",&n)&&n){
65 for(int i=0;i<n;i++) scanf("%d",&ar[i]);
66 int k=0,ans=nMAX-1;
67 for(int i=0;i<(1<<10);i++) {
68 if(ok(i)&&f[ans]>=f[i]){
69 if(f[ans]==f[i]&&number(ans)>number(i)) ans=i;
70 else if(f[ans]!=f[i])ans=i;
71 }
72 }
73 printf("Case %d: %d\n",T++,number(ans));
74 }
75 }



轉載于:https://www.cnblogs.com/louisnit/archive/2012/03/25/2417075.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/274934.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/274934.shtml
英文地址,請注明出處:http://en.pswp.cn/news/274934.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

qt ui指針和本類對象_您需要了解的有關UI設計的形狀和對象的所有信息

qt ui指針和本類對象重點 (Top highlight)第1部分 (Part 1) So you’re thinking about becoming a UX/UI designer, but are afraid to start? Don’t worry. It’s easier than you think. You only need a solid foundation and a lot of dedication. I can’t help you wi…

移動端h5頁面復制粘貼(兼容到ios9安卓4.0.0)

項目使用jquery框架純h5復制粘貼解決了iscroll4阻止所有默認事件&#xff0c;長按無法彈出復制菜單項目需要寫一個上拉加載頁面&#xff0c;頁面中的物流信息需要可復制粘貼&#xff0c;同時需要兼容到ios9和安卓4.0.0, 經過大量搜索&#xff0c;最終使用clipboard。代碼如下 &…

2021 大前端技術回顧及未來展望

大家好&#xff0c;我是若川。持續組織了6個月源碼共讀活動&#xff0c;感興趣的可以點此加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列2021 …

最近想讀的書想做的事

越來越多了&#xff0c;但是總是還沒開始&#xff0c;一天拿出一小時&#xff0c;周末拿出一上午。加油加油 2012/3/27 C標準庫 C專家編程Expert C Programming Deep C Secrets CodeCraft編程匠藝&#xff1a;編寫卓越的代碼 代碼之美 重看 編程珠璣 編程卓越之道 卷1 卷2 代碼…

skysat重訪周期_重訪小惡夢

skysat重訪周期You awaken with a start, the nightmare still fogging your mind with terror. Rain falls through cracks in the ceiling above you. The room is sparse, metallic, desolate. Searching the pockets of your yellow raincoat, you find only a cigarette l…

Python這些位運算的妙用,絕對讓你大開眼界

位運算的性能大家想必是清楚的&#xff0c;效率絕對高。相信愛好源碼的同學&#xff0c;在學習閱讀源碼的過程中會發現不少源碼使用了位運算。但是為啥在實際編程過程中應用少呢&#xff1f;想必最大的原因&#xff0c;是較為難懂。不過&#xff0c;在面試的過程中&#xff0c;…

記一次 Vue2 遷移 Vue3 的實踐總結

大家好&#xff0c;我是若川。持續組織了6個月源碼共讀活動&#xff0c;感興趣的可以點此加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列一、V…

改錯3-38

#include<iostream.h>class time{private:int hour,minute,second;public:void settime(int h,int m,int s) { hour(h>0&&h<24)?h:0; minute(m>0&&m<60)?m:0; second(s>0&&s<60)?s:0; }void sh…

魔獸懷舊網站模塊下載_一個人的網站重新設計和懷舊

魔獸懷舊網站模塊下載Despite how I look, I’m the kind kind of person that loves to play old video games. (Full disclosure: I look exactly like the kind of person that loves to play old video games).盡管我長得很帥&#xff0c;但我還是一個喜歡玩舊視頻游戲的人…

華為架構師談如何理解運用模塊與微服務

模塊化還是微服務&#xff1f; 我們的業務由一個大型應用轉向微服務的時候&#xff0c;除了很好展示漂亮的PPT&#xff0c;提升KPI之外&#xff0c;實際操作時將整個業務切成微型服務似乎也不費吹灰之力。但這種方法真的是我們的最佳選擇嗎&#xff1f;確實&#xff0c;維護凌亂…

Node.js 可以和 Web 實現 HTTP 請求的跨平臺兼容了!

大家好&#xff0c;我是若川。持續組織了6個月源碼共讀活動&#xff0c;感興趣的可以點此加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列大家好…

zeplin加載 不出圖片_為什么Zeplin不能解決您的所有問題

zeplin加載 不出圖片Design handover involves communicating the visual styles and behaviours of your design so they can be translated into code.設計移交涉及傳達設計的視覺樣式和行為&#xff0c;以便可以將它們轉換為代碼。 Back in the Dark Ages of digital desig…

POJ 基礎數學

數學 組合數學 POJ3252,poj1850,poj1019,poj1942 數論 poj2635, poj3292,poj1845,poj2115 計算方法&#xff08;二分&#xff09; poj3273,poj3258,poj1905,poj3122 組合數學 poj 3252 題意&#xff1a;如果一個數是round number&#xff0c;則它的二進制表示中&#xff…

使用uwsgi和gunicorn部署Django項目

https://uwsgi-docs.readthedocs.io/en/latest/Management.html https://uwsgi-docs.readthedocs.io/en/latest/Management.html 先了解下相關殺進程命令 ps -ef|grep uwsgi|grep -v grep|awk {print $2}|xargs kill -9//查看uwsgi相關接口 ps -ef|grep uwsgi #查看相關端口 ne…

推薦2022前端必看的新書 《Vue.js設計與實現》

大家好&#xff0c;我是若川。持續組織了6個月源碼共讀活動&#xff0c;感興趣的可以點此加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列這本新…

漢堡菜單_漢堡菜單-可訪問性和用戶體驗設計原則的挑戰?

漢堡菜單重點 (Top highlight)I was recently designing a hamburger menu for a client and before I knew it, I had embarked on this journey where I was reading article after article about the accessibility issues which accompany a hamburger icon. Turns out, th…

Server2012R2 ADFS3.0 The same client browser session has made '6' requests in the last '13'seconds

本問題是在windows server2012R2系統ADFS3.0環境下遇到的&#xff0c;CRM2013部署ADFS后運行一段時間(大概有一兩個月)后在IE瀏覽器中訪問登陸界面點擊登陸后就報以下錯誤 “Microsoft.IdentityServer.Web.InvalidRequestException: MSIS7042: The same client browser session…

(原創)RHEL/CentOS 5.x使用yum快速安裝MySQL 5.5.x

PS&#xff1a;MySQL 5.5系列成為穩定版已經有一段時間了&#xff0c;但據我調查了解&#xff0c;在生產環境中還是以5.1系列為主。在國內的大公司里&#xff0c;只確定金山在使用5.5了。 公司的其中幾臺廣告統計服務器&#xff0c;之前的運維直接用了自帶安裝的MySQL 5.0系列。…

又一個基于 Esbuild 的神器!esno

大家好&#xff0c;我是若川。持續組織了6個月源碼共讀活動&#xff0c;感興趣的可以點此加我微信 ruochuan02 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列esno我…

c# ui 滾動 分頁_UI備忘單:分頁,無限滾動和“加載更多”按鈕

c# ui 滾動 分頁重點 (Top highlight)When you have a lot of content, you have to rely on one of these three patterns to load it. So, which is best? What will your users like? What do most platforms use? These are the questions we will explore today.當內容…