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

组建网站需多少钱湖南室内设计公司排名

组建网站需多少钱,湖南室内设计公司排名,简单旅游网站模板下载,开网站挣不挣钱题意#xff1a; 给你n个小于101810^{18}1018的大数#xff0c;问在可以再不改变序列位置#xff0c;之改变数值中某数位的‘9’变为‘6’或将‘6’变为‘9’#xff0c;求的最终序列由小到大#xff0c;且字典序最小。 题目#xff1a; 链接#xff1a;https://ac.n…题意 给你n个小于101810^{18}1018的大数问在可以再不改变序列位置之改变数值中某数位的‘9’变为‘6’或将‘6’变为‘9’求的最终序列由小到大且字典序最小。 题目 链接https://ac.nowcoder.com/acm/contest/16741/H 来源牛客网 Woe is you – for your algorithms class you have to write a sorting algorithm, but you missed the relevant lecture! The subject was in-place sorting algorithms, which you deduce must be algorithms that leave each input number in its place and yet somehow also sort the sequence. Of course you cannot change any of the numbers either, then the result would just be a difffferent sequence. But then it hits you: if you flflip a 6 upside-down, it becomes a 9, and vice versa! Certainly no one can complain about this since you changed none of the digits! The deadline to hand in the exercise is in fifive hours. Try to implement this sorting algorithm before then! 输入描述: The input consists of: • A line with an integer n (2 ≤ n ≤ 10 000), the number of integers in the input sequence. • n lines, the ith of which contains a positive integer xi (1 ≤ xi ≤ 1018), the ith number of the sequence. 输出描述: If the sequence cannot be sorted non-decreasingly by flipping some number 6 or 9 in input 1, output “not possible”. Otherwise, output “possible” followed by the sorted sequence - each number on its own line. If there is more than one valid solution, please output the smallest sequence. 示例1 输入 4 9 7 7 9 输出 possible 6 7 7 9 示例2 输入 4 97 96 66 160 输出 possible 67 69 69 160 示例3 输入 3 80 97 79 输出 impossible 示例4 输入 2 197 166 输出 possible 167 169 分析 是一道比较容易的题但比赛时考虑太多wa了十几遍。。。下来看题解有点想吐血 废话不多说了下面看分析 贪心构造使每个串在大于等于前一个串的前提下尽可能小。注意字符串之间的大小比较与数字之间大小比较的不同以字符串形式输入数字。 依次遍历n个串分情况构造 当前串长度 前一个串长度。那直接把当前串的所有9变成6就可以了变完之后当前串肯定还是大于前一个串。当前串长度 前一个串长度。就算把当前串的所有6变成9也无力回天了直接impossible结束。当前串长度 前一个串长度。先还是把当前串的所有6变成9如果还是比前一个串小直接impossible结束否则从高位到低位依次尝试把9变回6这个时候要注意如果变了之后比前一个串小了那就说明不能变一定要还原回去 AC代码 #includestdio.h #includestring.h #includemath.h #includealgorithm #includeiostream using namespace std; typedef long long ll; const int M1e410; string a[M]; int n; bool solve(string f,int ii){if(f.size()a[ii-1].size()){for(int j0;jf.size();j)if(f[j]9)f[j]6;a[ii]f;}else{if(f.size()a[ii-1].size())return 0;for(int i0;if.size();i)if(f[i]6)f[i]9;if(fa[ii-1])return 0;for(int i0;if.size();i){if(f[i]9){f[i]6;if(fa[ii-1])f[i]9;}}a[ii]f;}return 1; } int main(){cinn;int vis0;a[0]0;for(int i1;in;i){cina[i];if(vis1)continue;if(!solve(a[i],i))vis1;}if(vis1) coutimpossibleendl;else{coutpossibleendl;for(int i1;in;i)couta[i]endl;}return 0; } 想了想还是抛上我比赛时地错误代码 分析 因为我没有分长度判断所以开了一个函数计算长度为101810^{18}1018的数值也是够够的比赛时的确注意到直接比较字符串的字典序由于长度的问题会有问题但是随即的解决方案搞了这么个吃力不讨好的。暴力莽想着对于所有6和9的出现位置可以先全部更为6然后进制枚举一下可能性将6变为9那么有2182^{18}218种排列数据量218∗1042^{18}*10^4218∗104妥妥的超时… #includestdio.h #includestring.h #includemath.h #includealgorithm #includemap #includeiostream using namespace std; typedef long long ll; const int M1e410; string a[M]; int b[M]; int n,tot; ll dfs(string f){ll ans0;int pf.size();for(int i0;ip;i){ansans*10f[i]-0;}return ans; } bool solve(string f,int ii){int ans1tot;for(int i0;ians;i){string wf;int ki;int kk0;while(k0){if(k%21){w[b[tot-1-kk]]9;}k/2;kk;}if(dfs(w)dfs(a[ii-1])){a[ii]w;return true;}}return false; } int main(){//while(1){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cinn;int vis0;a[0]0;for(int i1;in;i){cina[i];tot0;if(vis1)continue;string sa[i];int ls.size();for(int j0;jl;j){if(s[j]6)b[tot]j;if(s[j]9){b[tot]j;s[j]6;}}if(!solve(s,i))vis1;}if(vis1) coutimpossibleendl;else{coutpossibleendl;for(int i1;in;i)couta[i]endl;}//}return 0; }
http://www.zqtcl.cn/news/372535/

相关文章:

  • 广州做餐饮的招聘网站买毕业设计的网站
  • 涡阳网站建设网站开发工程师项目经验
  • 手机网站建站系统成都如何做网站
  • 安徽省住房和建设执业资格注册中心网站优质公司网站
  • 深圳福田做网站公司cname解析对网站影响
  • 做个网站要多久网站制作文案
  • 用户搭建网站wordpress代码实现头像
  • 和平区网站建设app和手机网站
  • 腾讯科技微信小程序电商seo是什么意思啊
  • 手机网站模板更换方法新闻客户端网站开发
  • 湛江定制建站黄页推广app软件
  • 盈利型网站做安卓app用什么软件
  • wordpress优秀移动站点西宁公司网站建设
  • 浙江网站建设的要求建设网上商城网站的目的和意义
  • 西峰住房和城乡建设局网站关于校园网站升级建设的报告
  • 网站怎么自适应屏幕大小达人室内设计网app
  • 做网站的软件名字全拼wordpress面包屑文字大小如何调整
  • 如何建设软件下载网站北京网站建设出名 乐云践新
  • 网站seo外包南宁网站建设活动
  • 汽车行业网站设计做互联网公司网站谈单模拟视频教学
  • 做网站界面设计注意什么江苏宿迁房产网
  • 传奇服务器网站如何建设帮人做兼职的网站
  • 织梦手机网站有广告位wordpress媒体库现实不全
  • 网站建设外包公司怎么样珠海网站排名提升
  • 电子商务网站建设结业论文做网站的图片字虚
  • 米拓建站最新进展注册做网站的公司有哪些
  • 设计网站设计wordpress 改系统
  • 学校网站建设评审会议通知网站是怎么赢利的
  • 手机网站建设 苏州优化网站哪个好
  • 网站建设流程方案通州网站建设公司