UVa 10018 - Reverse and Add
2012-12-13 15:33
323 查看
题目:给定把一个数字a,每次变为a和a的反转的加和,的那个a自反是停止。
分析:简单题。直接计算即可。
注意:数据范围超过int。
分析:简单题。直接计算即可。
注意:数据范围超过int。
#include <iostream> #include <cstdlib> using namespace std; typedef long long LL; LL rev( LL n ) { LL v = 0LL; while ( n ) { v *= 10LL; v += n%10LL; n /= 10LL; } return v; } int main() { int T; while ( cin >> T ) for ( int t = 1 ; t <= T ; ++ t ) { LL a,b; cin >> a; b = rev(a); int count = 0; while ( a != b ) { a = a+b; b = rev(a); count ++; } cout << count << " " << a << endl; } return 0; }
相关文章推荐
- UVA 10018 Reverse and Add
- UVa Problem Solution: 10018 - Reverse and Add
- UVA 10018 - Reverse and Add
- UVa10018 - Reverse and Add
- UVa OJ 10018-Reverse and Add
- UVa 10018 Reverse and Add (数学&利克瑞尔数)
- UVA10018 Reverse and Add【回文数+水题】
- UVa Problem 10018 Reverse and Add (反转相加)
- 10018 - Reverse and Add
- 10018 - Reverse and Add
- UVa——110502 Reverse and Add(数论)
- UVA 10018 and UVA 701 's reports.
- (挑战编程_5_2)Reverse and Add
- PC 110502 Reverse and Add //水题 字符串 模拟
- programming-challenges Reverse and Add (110502) 题解
- 110502 Reverse and Add
- 如何在eclipse中的tomcat不通过Add and Remove加载项目
- LeetCode 211.Add and Search Word - Data structure design(trie树)
- Differences Between 3 Types Of Proxy Servers: Normal, Transparent And Reverse Proxy
- UVa 10673 Play with Floor and Ceil(扩展欧几里得)