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

上海网站建设升级搜索引擎营销的方法有哪些

上海网站建设升级,搜索引擎营销的方法有哪些,跨境电商是什么意思,网站建设先进工作者CF1560D Make a Power of Two 题解题目链接字面描述题面翻译题目描述输入格式输出格式样例 #1样例输入 #1样例输出 #1提示思路代码实现备注题目 链接 https://www.luogu.com.cn/problem/CF1560D 字面描述 题面翻译 给定一个整数 nnn。每次操作你可以做两件事情中的一件 删去这个数中的一个数位如果这个数只剩下一位则可以把它删空。在这个数的右边添加一个数位。 你可以以任意顺序执行无限次操作。但请注意在删去一个数位之后这个数可能包含前导零例如在删去 301301301 中的 333 这一位之后这个数就会变成 010101 而不是 111。 你需要执行若干次操作使得这个数最终变成一个 222 的次幂或者说存在一个非负整数 kkk 使得这个数最终是 2k2^k2k。最终答案不能包含前导零。请求出需要执行的操作的最小次数。 ttt 组数据1⩽t⩽1041\leqslant t\leqslant 10^41⩽t⩽1041⩽n⩽1091\leqslant n\leqslant 10^91⩽n⩽109。 题目描述 You are given an integer $ n $ . In $ 1 $ move, you can do one of the following actions: erase any digit of the number (it’s acceptable that the number before the operation has exactly one digit and after the operation, it is “empty”);add one digit to the right. The actions may be performed in any order any number of times. Note that if, after deleting some digit from a number, it will contain leading zeroes, they will not be deleted. E.g. if you delete from the number $ 301 $ the digit $ 3 $ , the result is the number $ 01 $ (not $ 1 $ ). You need to perform the minimum number of actions to make the number any power of $ 2 $ (i.e. there’s an integer $ k $ ( $ k \ge 0 $ ) such that the resulting number is equal to $ 2^k $ ). The resulting number must not have leading zeroes. E.g. consider $ n1052 $ . The answer is equal to $ 2 $ . First, let’s add to the right one digit $ 4 $ (the result will be $ 10524 $ ). Then let’s erase the digit $ 5 $ , so the result will be $ 1024 $ which is a power of $ 2 $ . E.g. consider $ n8888 $ . The answer is equal to $ 3 $ . Let’s erase any of the digits $ 8 $ three times. The result will be $ 8 $ which is a power of $ 2 $ . 输入格式 The first line contains one integer $ t $ ( $ 1 \le t \le 10^4 $ ) — the number of test cases. Then $ t $ test cases follow. Each test case consists of one line containing one integer $ n $ ( $ 1 \le n \le 10^9 $ ). 输出格式 For each test case, output in a separate line one integer $ m $ — the minimum number of moves to transform the number into any power of $ 2 $ . 样例 #1 样例输入 #1 12 1052 8888 6 75 128 1 301 12048 1504 6656 1000000000 687194767样例输出 #1 2 3 1 3 0 0 2 1 3 4 9 2提示 The answer for the first test case was considered above. The answer for the second test case was considered above. In the third test case, it’s enough to add to the right the digit $ 4 $ — the number $ 6 $ will turn into $ 64 $ . In the fourth test case, let’s add to the right the digit $ 8 $ and then erase $ 7 $ and $ 5 $ — the taken number will turn into $ 8 $ . The numbers of the fifth and the sixth test cases are already powers of two so there’s no need to make any move. In the seventh test case, you can delete first of all the digit $ 3 $ (the result is $ 01 $ ) and then the digit $ 0 $ (the result is $ 1 $ ). 思路 本题最终的目的是将一个[1,1e9]的整数通过2种操作变为2的非负整数次幂。 将20 - 255 每一个数位上的数打表预处理用原数列一一与表中元素比较计算操作次数记录最小值。 时间复杂度: O(10t)≈1e5O(10t)≈1e5O(10t)≈1e5 代码实现 #includebits/stdc.h #define ll long long using namespace std;const int maxn100; const int inf2e9; int t,ansinf,tot; ll op1,x; ll a[maxn]; int k[maxn];//记录表中每一元素的长度 ll cnt[maxn][maxn]; int main(){//预处理k[0];cnt[0][1]1;for(int i1;i55;i){op(ll)op*2;ll op1op;while(op1){cnt[i][k[i]](ll)op1%10;op1(ll)op1/10;}}/*for(int i1;i40;i){for(int jk[i];j1;j--)printf(%lld,cnt[i][j]);printf(\n);}*/scanf(%d,t);while(t--){ansinf;scanf(%lld,x);tot0;while(x){a[tot](ll)x%10;x(ll)x/10;}//for(int itot;i1;i--)printf(%d,a[i]);//计算比较for(int i0;i55;i){int st1tot,st2k[i];while(st10st20){if(a[st1]cnt[i][st2])--st2;--st1;}//if(i41)printf(41 %d %d\n,k[i],st2);ansmin(ans,tot-k[i]2*st2);// tot-(k[i]-st2) 删除的操作次数操作次数 st2 添加的操作次数}printf(%d\n,ans);}return 0; }备注 写入好题本
http://www.dnsts.com.cn/news/191811.html

相关文章:

  • 网站推广郑州免费白嫖国外服务器app
  • 网站构建的基本流程五个环节《传奇世界》官网
  • 个体工商户经营范围做网站电子商务这个专业好吗
  • 通化市网站建设网站建设案例收费情况
  • 天津网站制作培训马蜂窝旅游网站怎么做
  • 企业网站建设优化广东深圳是一个城市吗
  • 大型网站开发协调如何入侵网站后台密码
  • 哪家网站推广做的好辽宁城乡住房建设厅官网证书查询
  • 大连市建设工程老网站电子商务平台网站建设方式
  • 北京赛车网站开发河南网站建设 网站制作 网站设计
  • 黄石港区建设局网站网站开发介绍ppt
  • 网站建设彳金手指排名网页设计公司背景
  • 关于做电影的网站设计垦利县建设局网站
  • 云南省建设厅网站二级建造师用旧手机做网站服务器
  • 论坛静态网站源码免费的简历制作
  • 潍坊仿站定制模板建站上海百度推广优化公司
  • 宝塔面板做网站不能打开PHP显示404大连关键词快速排名
  • 网站开发 图形验证码鹏鹞网站页面代码
  • 建站收入企业档案网站建设
  • 福清市建设局官方网站建网站要多少钱 东莞
  • 河南联通 网站备案建立什么船籍港
  • 电子商务网站会员体系wordpress 导航文字图片
  • 看网站搜什么关键词苏州本地网站有哪些
  • 建设银行网站注销吗自建站怎么推广
  • 帝国cms网站地图xml做网站的电脑配置
  • 大连做企业网站哪家好成都企业网站建设公司电话
  • 服务器做网站FTP必要性大吗南宁企业自助建站系统
  • 珠海建设企业网站的公司小企业怎么推广
  • 软件网站技术开发公司旅游网站模板库
  • 保亭县住房城市建设局网站jsp网站开发目的及意义