枚举-生成元3.5Digit generator
来源:互联网 发布:终端如何退出python 编辑:程序博客网 时间:2024/05/16 19:10
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<ctime>
#define maxn 100005
#define mem(a,b) memset((a),(b),sizeof((a)))
using namespace std;
int main()
{
int T,n;
int ans[maxn];
mem(ans,0);
for(int m=1;m<maxn;m++)
{
int x=m,y=m;
while (x>0)
{
y+=x%10; //数字的末尾数 y = y + x % 10
x/=10; //x=x/10 数字的前半部分
}
if(ans[y]==0||m<ans[y]) //ans[y]==0||m<ans[y]
ans[y]=m;
}
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
printf("%d\n",ans[n]);
}
return 0;
}
#include<cstring>
#include<algorithm>
#include<ctime>
#define maxn 100005
#define mem(a,b) memset((a),(b),sizeof((a)))
using namespace std;
int main()
{
int T,n;
int ans[maxn];
mem(ans,0);
for(int m=1;m<maxn;m++)
{
int x=m,y=m;
while (x>0)
{
y+=x%10; //数字的末尾数 y = y + x % 10
x/=10; //x=x/10 数字的前半部分
}
if(ans[y]==0||m<ans[y]) //ans[y]==0||m<ans[y]
ans[y]=m;
}
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
printf("%d\n",ans[n]);
}
return 0;
}
0 0
- 枚举-生成元3.5Digit generator
- 例题3-5 生成元(Digit Generator)
- UVA1583 - Digit Generator(生成元,打表)
- Uva(Digit Generator,1583) 生成元
- Digit Generator 生成元(P52) / UVA
- 生成元(Digit Generator,ACM/ICPC Seoul 2005, UVa1583)
- 生成元(Digit Generator, ACM/ICPC Seoul 2005, UVa1583)
- UVa1583 - Digit Generator 生成元 (java版本)
- 最小生成元 (Digit Generator, ACM/ICPC Seoul 2005, UVa1583)
- 生成元(Digit Generator, ACM/ICPC Seoul 2005, UVa1583)
- UVA 1583 Digit Generator(最小生成元+打表)
- 《算法竞赛入门经典2ndEdition 》例题3-5 生成元(Digit Generator, Uva1583)
- Digit Generator
- Digit Generator
- UVa 1583 Digit Generator(枚举+打表)
- UVa 1583 Dighter Generator(生成元)
- 1325. Digit Generator
- sicily--1325. Digit Generator
- MySQL常用脚本
- JS实现点击复选框变更DIV显示状态实例
- swift中UITextView的使用
- 让lua的gc替我们回收c的堆变量
- Til the Cows Come Home (Digkstra邻接矩阵裸模板)
- 枚举-生成元3.5Digit generator
- I2C
- Python练习实例16
- Objective-c - 构造方法(init方法)和init方法的重写
- SpringBoot Scala敏捷Web开发
- GOF23的一些总结(十五)
- 前端自学vs跟大神系统学?你看着办
- 聊天机器人学习笔记整理系列:POMDP-based Statistical Spoken Dialogue System: a Review
- I - Red and Black