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

网站建设公司哪家好 地址磐石网络miit网站备案

网站建设公司哪家好 地址磐石网络,miit网站备案,企查查个人信息查询,汕头网站开发找哪里Minimum Varied Number 题面翻译 题目描述 找出数码和为 s s s 的最小数字#xff0c;使得其中的所有数字都是不同的#xff08;即所有数字都是唯一的#xff09;。 例如#xff0c;如果 s 20 s20 s20 #xff0c;那么答案是 389 389 389。这是最小的数字#xf…Minimum Varied Number 题面翻译 题目描述 找出数码和为 s s s 的最小数字使得其中的所有数字都是不同的即所有数字都是唯一的。 例如如果 s 20 s20 s20 那么答案是 389 389 389。这是最小的数字其中所有数字都不同数字的总和为 20 20 20 3 8 9 20 38920 38920。 对于给定的 s s s 输出这个最小数字。 输入格式 第一行包含整数 t t t ( 1 ≤ t ≤ 45 1≤t≤45 1≤t≤45 — 测试用例的数量。 每个测试用例由包含一行唯一整数指定的 s s s ( 1 ≤ s ≤ 45 1≤s≤45 1≤s≤45)。 输出格式 输出 t t t 个整数 ― 给定测试用例的答案。 样例解释 对于第一个测试用例 s 20 s20 s20最小数字为 389 389 389。 对于第二个测试用例 s 8 s8 s8最小数字为 8 8 8 8 8 88 88。 对于第一个测试用例 s 45 s45 s45最小数字为 123456789 123456789 123456789 1 2 3 4 5 6 7 8 9 45 12345678945 12345678945。 对于第一个测试用例 s 10 s10 s10最小数字为 19 19 19 1 9 10 1910 1910。 题目描述 Find the minimum number with the given sum of digits $ s $ such that all digits in it are distinct (i.e. all digits are unique). For example, if $ s20 $ , then the answer is $ 389 $ . This is the minimum number in which all digits are different and the sum of the digits is $ 20 $ ( $ 38920 $ ). For the given $ s $ print the required number. 输入格式 The first line contains an integer $ t $ ( $ 1 \le t \le 45 $ ) — the number of test cases. Each test case is specified by a line that contains the only integer $ s $ ( $ 1 \le s \le 45 $ ). 输出格式 Print $ t $ integers — the answers to the given test cases. 样例 #1 样例输入 #1 4 20 8 45 10样例输出 #1 389 8 123456789 19Solution 采用贪心的策略为了使数字最小则必须保证低数位数一定是最大的 首先从9-1开始选取最大的数字若数字之和小于 s s s则放入 n n n中并计算 n n n中的数字和当数字之和n等于s时退出循环返回n数字之和大于 s s s则不进行处理 // // Created by Gowi on 2023/12/2. //#include iostream #include cmathusing namespace std;int main() {int t;cin t;while (t--) {int s, n 0, sum 0, v 0;cin s;for (int i 9; i 0; i--) {if (sum i s) {n i * pow(10, v) n;sum i;v;}if (sum s) {break;}}cout n endl;}return 0; }
http://www.zqtcl.cn/news/250244/

相关文章:

  • 农业信息门户网站建设方案教做糕点的网站
  • 网站上的分享手机网站免费建设平台
  • 有哪个网站专业做漫画素材的wordpress显示问题
  • 网站开发工程师月薪网站网页设计培训机构
  • 专业网站运营备案名称网站名称
  • 盐城市建设局网站企业网站建设流程与方法 论文
  • 青岛信息推广网站营销自己的网站
  • wp博客 婚庆网站模板摄影网页面制作
  • 大型商城网站建设学计算机前端好就业吗
  • 杭州 电子商务网站建设专门做酒店自助餐的网站
  • 如何备份网站数据库网站用户体验模型
  • 网站域名注册流程办公室装修风格
  • a站免费最好看的电影片推荐方正隶变简体可以做网站用么
  • 创同盟做网站找公司做网站需要咨询什么问题
  • 西安行业网站株洲高端网站建设
  • 优化网站流量商城网站建设软件
  • dw属于什么的网页制作工具网络建站优化科技
  • 百度网站首页的设计理念南京高新区规划建设局网站
  • 虚拟机做实验的网站网站以个人名义备案
  • 自定义表单网站网站建设营销型号的区别
  • 有个网站做彩盒的贵阳网站建设托管
  • 网站制作属于什么专业做网站需要什么配置服务器吗
  • 网站开发学习培训广州网站优化关键词公司
  • 毕节金海湖新区城乡建设局网站企业网站的步骤
  • 网站后台设计教程网站建设判断题
  • 珠海网站建设 金蝶天元建设集团有限公司李华
  • 海安市建设局网站成都官网seo技术
  • 网站建设策划书结束语wordpress付费版
  • 进口网站建设做网站用什么格式的图片
  • 青海省住房和城乡建设部网站进入网站空间