A+A的每一位的数字的和=B

问你每一个B对应 的最小的A 是多少

不然输出0;

 #include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
const int N=;
int ans[*N],tmp,cnt,n,t;
void fuc(){
memset(ans,,sizeof(ans));
for(int i=;i<=N;i++){
tmp=i; cnt=;
while(tmp>){
cnt+=tmp%;
tmp/=;
}
cnt+=i;
if(ans[cnt]==) ans[cnt]=i;
}
}
int main()
{
fuc();
scanf("%d",&t);
while(t--){
scanf("%d",&n);
printf("%d\n",ans[n]);
}
}

UVa 1583 - Digit Generator的更多相关文章

  1. UVa 1583 Digit Generator --- 水题+打表

    UVa 1583 题目大意:如果x加上x的各个数字之和得到y,那么称x是y的生成元. 给定数字n,求它的最小生成元 解题思路:可以利用打表的方法,提前计算出以i为生成元的数,设为d,并保存在a[d]中 ...

  2. UVa 1583 Digit Generator(数学)

     题意 假设a加上a全部数位上的数等于b时 a称为b的generator  求给定数的最小generator 给的数n是小于100,000的  考虑到全部数位和最大的数99,999的数位和也才45 ...

  3. UVa 1583 - Digit Generator 解题报告 - C语言

    1.题目大意 如果a加上a的各个数字之和得到b,则说a是b的生成元.给出n其中$1\le n\le 100000$,求其最小生成元,若没有解则输出0. 2.思路 使用打表的方法打出各个数字a对应的b, ...

  4. uva 1583 Digit Generator(Uva-1583)

    题目不再写入了,vj:https://vjudge.net/problem/UVA-1583#author=0 主要讲的是找一个数的小于它的一个数,小于它的那个数每一位加起来再加上那个数就会等于原来的 ...

  5. UVa 1583 Digit Generator WA

    #include<stdio.h> int main() { long int n,i,s=0; while(scanf("%d",&n)!=EOF) { in ...

  6. UVa 1225 Digit Counting --- 水题

    UVa 1225 题目大意:把前n(n<=10000)个整数顺次写在一起,12345678910111213...,数一数0-9各出现多少字 解题思路:用一个cnt数组记录0-9这10个数字出现 ...

  7. Digit Generator(水)

    题目链接:http://acm.tju.edu.cn/toj/showp2502.html2502.   Digit Generator Time Limit: 1.0 Seconds   Memor ...

  8. [C++]最小生成元 (Digit Generator, ACM/ICPC Seoul 2005, UVa1583)

    Question 例题3-5 最小生成元 (Digit Generator, ACM/ICPC Seoul 2005, UVa1583) 如果x+x的各个数字之和得到y,就是说x是y的生成元.给出n( ...

  9. 【UVA 1583】Digit Generator

    题 题意 a加上 a的各位数=b,则b是a的digitSum,a是b的generator,现在给你digitSum,让你求它的最小的generator. 分析 一种方法是: 预处理打表,也就是把1到1 ...

随机推荐

  1. eclipse美化,全黑eclipse 保护眼睛

    如标题,闲话不多说.有图说明一切.看看这是你想要的嘛? 教程及资源下载地址: http://download.csdn.net/detail/shoneworn/8326097

  2. HttpApplication事件执行顺序(转)

    HttpApplication 类的实例(Global继承自该类)是在 ASP.NET 基础结构中创建的,而不是由用户直接创建的.HttpApplication 类的一个实例在其生存期内被用于处理多个 ...

  3. SFTP CONFIGURATION IN FLASHFXP PROGRAM

    This is a brief guide on how to configure the FlashFXP FTP client to log on to the domain web space ...

  4. iOS框架介绍

    iOS框架介绍      Cocoa Touch   GameKit  实现对游戏中心的支持,让用户能够在线共享他们的游戏相关的信息  iOS设备之间蓝牙数据传输   从iOS7开始过期   局域网游 ...

  5. (原创) C# List 找 Max 的 Index

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  6. 【Remoting-5代码实现】

    服务端 class RemotingServiceHelper { private static string m_protocolType; private static string urlStr ...

  7. sql 函数 总结

    聚合函数 Avg(numeric_expr)返回integer.decimal.money.float---返回组中各值的平均值 Count(*|column_name|distinct column ...

  8. HDU 1056 - HangOver

    递推 #include <iostream> using namespace std; ]; double c; int main() { f[]=; ;i<=;i++) f[i]= ...

  9. W - Bitset(第二季水)

    Description Give you a number on base ten,you should output it on base two.(0 < n < 1000)      ...

  10. openstack安装记录(二)keystone安装

    先决条件 在你配置 OpenStack 身份认证服务前,你必须创建一个数据库和管理员令牌. 完成下面的步骤以创建数据库: 用数据库连接客户端以 root 用户连接到数据库服务器: $ mysql -u ...