A. Sequence with Digits
A. Sequence with Digits
A.数字序列
time limit per test: 1 second
每次测试的时间限制:1秒
memory limit per test: 256 megabytes
每次测试的内存限制:256兆字节
input: standard input
input: standard input
output: standard output
output: standard output
Let’s define the following recurrence:
Let’s define the following recurrence:
an+1= an + minDigit(an) . maxDigit(an).
A+1=an+minDigit(An)最大数字(AN)
Here minDigit(x ) and max Digit(x ) are the minimal and maximal digits in the decimal representation of x without leading zeroes. For
Here minDigit(x ) and max Digit(x ) are the minimal and maximal digits in the decimal representation of x without leading zeroes. For
examples refer to notes.
examples refer to notes.
Your task is calculate aK for given a1 and K.
Your task is calculate aK for given a1 and K.
Input
输入
The first line contains one integert(1≤t < 1000)一the number of independent test cases.
第一行包含一个整数(1≤t<1000)一独立测试用例数。
Each test case consists of a single line containing two integers a1 andK (1≤a1≤1018.1≤K≤101) separated by a space.
Each test case consists of a single line containing two integers a1 andK (1≤a1≤1018.1≤K≤101) separated by a space.
Output
输出量
For each test case print one integer ak on a separate line.
对于每个测试用例,在单独的行上打印一个整数AK。
模拟
ll min(ll n)
{ll a = 11;while(n){a = min(a,n%10);n /= 10;if(a == 0) break;}return a;
}
ll max(ll n)
{ll a = -1;while(n){a = max(a,n%10);n/= 10;if(a == 9) break;}return a;
}
int main()
{int t;cin >> t;while(t--){ll n,k;cin >> n >> k;for(int i = 1;i < k;++i){if(min(n) == 0)break;n += min(n)*max(n);}cout << n << endl;}
}
A. Sequence with Digits相关推荐
- Sequence with Digits CodeForces - 1355A(暴力+数学)
题意: 定义: an+1=an+minDigit(an)×maxDigit(an). 给定 a1 和 k,求 ak ? 题目: Let's define the following recurrenc ...
- codeforce A - Sequence with Digits
链接 已知递推公式,告诉a1,和k,求ak 每个数字各位中最大的数字,和最小的数字相乘. 比如513,minDigit(513)=1,maxDigit(513)=5 数据量 暴力long long最大 ...
- A.Digits Are Not Just Characters---2018横滨区域赛(大模拟)
Digits Are Not Just Characters Time Limit: 2 Sec Memory Limit: 256 Mb 题目链接http://acm.csu.edu.cn:2008 ...
- Dynamic Expressions and Queries in LINQ
[索引页] 这篇是在LinqSamples中关于Dynamic LINQ的文档.今天看后就把它翻译过拉.不知道有没有官方的中文版,但我都翻译拉所以就发上来拉..如果你没有去ms下,你可以点这里 请指正 ...
- UVA 621 Secret Research
额.. 不理解这题为什么会是数学题 0.0 可能是输入中有很长的字符串需要处理,然后获得字符串的位数是一个需要技巧的过程? 不过我直接STL过的 ...真心感觉STL很方便 但是也不能依赖STL额.. ...
- Codeforces Round #572 (Div. 2)(ABCD1D2E)
Keanu Reeves CodeForces - 1189A After playing Neo in the legendary "Matrix" trilogy, Keanu ...
- Codeforces Round #643 (Div. 2)(A, B, C, D, E)
Codeforces Round #643 (Div. 2) Sequence with Digits 思路 一道暴力题,猜想在某一步一定会出现0,于是怀着忐忑提交了代码,结果还真的是这样. 代码 # ...
- 【362】python 正则表达式
参考:正则表达式 - 廖雪峰 参考:Python3 正则表达式 - 菜鸟教程 参考:正则表达式 - 教程 re.match 尝试从字符串的起始位置匹配一个模式,如果不是起始位置匹配成功的话,match ...
- UVA621 Secret Research【水题】
At a certain laboratory results of secret research are thoroughly encrypted. A result of a single ex ...
最新文章
- mysql分页原理和高效率的mysql分页查询语句
- Flink实例-Wordcount详细步骤
- Android JNI编程(六)——C语言函数指针、Unition联合体、枚举、Typedef别名、结构体、结构体指针...
- 无法创建Web Application项目的问题
- ImportError: module ‘pip‘ has no attribute ‘main‘
- Travis CI + github + hexo 自动化部署
- TypeScript Partial 使用的一个小技巧
- 教育部推出首批490门“国家精品在线开放课程”
- Qt笔记-Linux程序打印带颜色的字符串
- 编程体系结构(06):Java面向对象
- (组合数学笔记)Pólya计数理论_Part.9_Pólya定理的推广——De Bruijn定理
- SqlServer修改密码后登陆不上
- simplex字体下载cad_CAD字体大全【资料下载】
- Android 关于内存泄漏的一些总结
- 合金理论自动化工具包(Alloy-Theoretic Automated Toolkit:ATAT)的安装
- oracle怎么用dmp文件,oracle 11g 如何打开dmp文件
- Java反射机制详解上篇
- linux unlink函数作用,unlink函数的作用
- wox开机自启_Wox具有一切支持的Windows启动器
- 网页连接服务器失败是怎么回事,网页怎么连接服务器失败是怎么回事