UVa 1583 Digit Generator
来源:互联网 发布:淘宝客如何用qq群赚钱 编辑:程序博客网 时间:2024/06/07 09:41
Description
一个数
自己加各个数位之和形成一个新数
245 is 256 (= 245 + 2 + 4 + 5).
然后256可能有很多种数组成了,找到最小的,输出
Algorithm
直接枚举,用a[i]表示组成i的最小的数
最后输出a[i]即可
Code
import java.util.Scanner;public class Main { public static void main(String args[]) { final int maxn = 100000 + 9; Scanner cin = new Scanner(System.in); int t = cin.nextInt(); int[] a = new int[2 * maxn]; for (int i = 0; i < maxn; i++) { int x = i; int s = x; while (x > 0) { s += (x % 10); x /= 10; } if (a[s] > 0) continue; a[s] = i; } while (t-- > 0) { int n = cin.nextInt(); System.out.println(a[n]); } }}
0 0
- UVA-1583 - Digit Generator
- UVa 1583 Digit Generator
- UVa 1583 - Digit Generator
- UVA 1583 - Digit Generator
- UVa 1583 Digit Generator
- UVa 1583 - Digit Generator
- UVa-1583Digit Generator
- 【Uva 1583】 Digit Generator
- UVA - 1583 Digit Generator
- Uva - 1583 - Digit Generator
- UVA - 1583 Digit Generator
- UVa 1583 - Digit Generator
- UVA 1583 Digit Generator
- UVa 1583 Digit Generator
- UVA - 1583 Digit Generator
- UVa 1583 - Digit Generator
- UVa 1583 - Digit Generator
- UVa 1583 - Digit Generator
- 半导体二极管及直流稳压电源
- android viewpager指示器管理,拖动排序,添加删除动画
- Fragment动态添加碎片
- 修复Ubuntu引导
- 背景建模与前景检测3(Background Generation And Foreground Detection Phase 3)
- UVa 1583 Digit Generator
- Swift的protocol与协议扩展
- 详解 B-Tree 与B+Tree
- 打字感受
- EasyDarwin服务部署与集成(HLS/CMS/RMS/Android客户端)---(1)
- 关于easyUI的清空按钮的方法
- debian修复/dev/mapper/debian--vg-root文件错误导致ehci-orion not found in modules.dep
- 使用ftp4j类来实现FTP操作
- GDOI2016总结