当前位置: 首页 > 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.pierceye.com/news/250244/

相关文章:

  • 银川网站建设一条龙服务服装行业网站模板
  • 重庆建站程序建筑网站起名
  • 便宜网站制作wordpress函数手册
  • 适合在家做的网站工作做音乐网站要求
  • 在哪个网站做视频赚钱的建设彩票网站需要多少投资
  • 大连网站建设意动科技推荐做那个的电影网站
  • 博达 网站群建设wordpress打开乱码
  • 电商网站建设代理商定制网站开发介绍图
  • 网站系统问题解决措施上海网站建设系
  • c 做网站简单吗ui设计需要学什么软件
  • 网站建设app开发公司国内免备案空间
  • nas 支持做网站dedecms 做影网站
  • 网上商城网站模板广州建设技术职业学院
  • 养生网站模板下载山东网站建设哪家专业
  • 最新电子产品网站模板网站建设公司 腾佳
  • 跟公司产品做网站用什么程序做网站最好优化
  • 在线代理网页浏览网站山东省城乡住房建设厅网站
  • 网站建设需准备什么彩页模板图片
  • 怎么用网站源码建站网站换空间步骤
  • 酒店网站开发回扣商丘企业网站建设服务
  • 网站建设策划解决方案河北自助建站系统平台
  • 有没有做高仿手表的网站设计师的职责
  • struts2 做的网站seo公司怎样找客户
  • 帮别人做网站赚钱吗中山快速建站合作
  • 保靖网站建设做网站要运用到代码吗
  • 我用织梦5.7做个网站应该把淘宝客店铺链接放到哪frontpage可以制作网页吗
  • 潍坊优化网站排名在线网页设计培训机构
  • c做的网站ps做 网站标准尺寸
  • 老虎淘客系统可以做网站吗wordpress po mo
  • 网站的建设与维护那个网站做图片好