当前位置: 首页 > news >正文

网站为什么会出现死链西安优化seo

网站为什么会出现死链,西安优化seo,ui设计难学么,电商多用户商城源码题意&#xff1a;给定n&#xff0c;m&#xff0c;c 和 k个数 求最小的一个数&#xff08;这个数是c进制&#xff0c;且是n的倍数&#xff09; 一共5000个状态&#xff0c;bfs 不会写DFS啊。。。。 不过看了别人的BFS后还是有种恍然大悟的感觉。。。。 View Code 1 #include<…

题意:给定n,m,c 和 k个数

求最小的一个数(这个数是c进制,且是n的倍数)

一共5000个状态,bfs

不会写DFS啊。。。。

不过看了别人的BFS后还是有种恍然大悟的感觉。。。。

View Code
  1 #include<stdio.h>
  2 #include<stdlib.h>
  3 #include<string>
  4 #include<algorithm>
  5 #include<math.h>
  6 #include<iostream>
  7 #include<queue>
  8 using namespace std;
  9 const int maxn = 24;
 10 const int maxm = 5105;
 11 const int inf = 99999999;
 12 int n,m,c;
 13 int a[ maxn ];
 14 int vis[ maxm ];
 15 int flag;
 16 struct node{
 17     string ans;
 18     int mod;
 19 };
 20 string res;
 21 queue<node>q;
 22 void init2(){
 23     while( !q.empty() )
 24         q.pop();
 25 }
 26 void init1(){
 27     memset( a,0,sizeof( a ));
 28     memset( vis,0,sizeof( vis ));
 29     flag=-1;
 30     res.clear();
 31 }
 32 void bfs(){
 33     init2();
 34     node now,next;
 35     for( int i=1;i<16;i++ ){
 36         if( a[i] ){
 37             vis[ i%n ]=1;
 38             if( i>=0&&i<=9 ){
 39                 now.ans="";
 40                 now.ans=(i+'0');
 41                 now.mod=i%n;
 42                 q.push( now );
 43             }
 44             else{
 45                 now.ans="";
 46                 now.ans=(i+'A'-10);
 47                 now.mod=i%n;
 48                 q.push( now );
 49             }
 50         }
 51     }//the init
 52     while( !q.empty() ){
 53         now=q.front(),q.pop();
 54         if( flag==1&&now.ans.size()>res.size() )
 55             continue;
 56         if( now.mod==0 ){
 57             if( flag==-1 ){
 58                 flag=1;
 59                 res=now.ans;
 60             }
 61             else{
 62                 if( now.ans.size()<res.size() ){
 63                     res=now.ans;
 64                 }
 65                 else if( now.ans.size()==res.size()&&res>now.ans ){
 66                     res=now.ans;
 67                 }
 68             }
 69         }
 70         for( int i=0;i<16;i++ ){
 71             if( a[i] ){
 72                 if( i<10 ){
 73                     next=now;
 74                     next.ans+=( i+'0' );
 75                     next.mod=(now.mod*c+i)%n;
 76                     if( ( next.ans.size()<=500&&vis[ next.mod ]==0 )||( next.mod==0 ) ){
 77                         vis[ next.mod ]=1;
 78                         q.push( next );
 79                     }
 80                 }
 81                 else{
 82                     next=now;
 83                     next.ans+=(i+'A'-10);
 84                     next.mod=(now.mod*c+i)%n;
 85                     if( ( next.ans.size()<=500&&vis[ next.mod ]==0 )||( next.mod==0 ) ){
 86                         vis[ next.mod ]=1;
 87                         q.push( next );
 88                     }
 89                 }
 90             }
 91         }
 92     }
 93 }
 94 
 95 int main(){
 96     int ca;
 97     scanf("%d",&ca);
 98     while( ca-- ){
 99         scanf("%d%d%d",&n,&c,&m);
100         init1();
101         char ch[ 4 ];
102         for( int i=0;i<m;i++ ){
103             scanf("%s",ch);
104             if( ch[0]>='0'&&ch[0]<='9' )
105                 a[ ch[0]-'0' ]=1;
106             else
107                 a[ ch[0]-'A'+10 ]=1;
108         }
109          if(n==0){  
110            // cout<<0<<endl;  
111             if(a[0]==1)  
112                 cout<<0<<endl;  
113             else  
114                 cout<<"give me the bomb please"<<endl;  
115             continue;  
116         }  
117         bfs();
118         if( flag==-1 )
119             printf("give me the bomb please\n");
120         else
121             cout<<res<<endl;
122     }
123     return 0;
124 }

 

转载于:https://www.cnblogs.com/xxx0624/archive/2013/02/27/2935828.html

http://www.lbrq.cn/news/2485027.html

相关文章:

  • 福州网站建设方案管理人员课程培训
  • 做美女图片网站犯法吗杭州seo代理公司
  • 徐州如何选择网站建设热搜词工具
  • 网站权重有什么用国内重大新闻10条
  • 连江建设局网站外贸全网营销推广
  • 做一个购物商城网站多少钱seo助力网站转化率提升
  • 一个网站做数据维护3天正常吗天津seo方案
  • 一级a做爰片拍网站网站关键词优化费用
  • 网站备案需要哪些资料网络维护公司
  • 家电网站制作搜索引擎关键词怎么优化
  • 英文网站建设解决方案seo优化视频教程
  • 广州市从化区住房和建设局网站搜索引擎优化关键词选择的方法有哪些
  • 做任务打字赚钱的网站西安网站快速排名提升
  • 网站更新后 需要更新 sitemap 吗seo营销论文
  • 本溪做网站的公司seo的培训课程
  • 丰城网站建设网站收录平台
  • 唐山做网站优化如何建站
  • 上海展厅网站关键词优化案例
  • 做网站需要备案么网络推广
  • 官方网站下载免费app怎么注册中视频账号
  • 网站用空间还是服务器怎么制作微信小程序
  • 上海交通公安门户网站广州网络优化最早的公司
  • 厦门集美建设局网站广州最新疫情最新消息
  • 乾县做网站网络推广赚钱项目
  • 手机网站建设做竞价推广的技巧2023b站免费推广入口游戏
  • 咨询公司招聘青岛百度seo
  • 小程序流量主骗局网络优化工程师有前途吗
  • 网站关键词排名检测工具成都公司网站seo
  • 海口网站建设中心网络宣传推广方案
  • 深圳建站企业百度销售平台怎样联系
  • 自由学习记录(74)
  • sealos 方式安装k8s5节点集群
  • C++类和对象(三)
  • sklearn库中有关于数据集的介绍
  • Java操作Excel文档
  • 泰山派GPIO编译 ADB下载 万用表测量GPIO电压