LA 2889 回文(找规律)
2016-03-01 20:21
344 查看
#include <string> #include <iostream> using namespace std; int n; int main() { while (cin >> n && n) { long long x = 0; while (n > x * 2) x = x * 10 + 9; bool flag = 0; if (n > x + x / 10) flag = 1; n -= (flag ? x : x / 10); string str = to_string(n); string kstr(str.rbegin(), str.rend()); if (flag) str += kstr; else str += kstr.substr(1, str.length() - 1); cout << str << endl; } return 0; }
打表找规律
第1到100:
1
2
3
4
5
6
7
8
9
11
22
33
44
55
66
77
88
99
101
111
121
131
141
151
161
171
181
191
202
212
222
232
242
252
262
272
282
292
303
313
323
333
343
353
363
373
383
393
404
414
424
434
444
454
464
474
484
494
505
515
525
535
545
555
565
575
585
595
606
616
626
636
646
656
666
676
686
696
707
717
727
737
747
757
767
777
787
797
808
818
828
838
848
858
868
878
888
898
909
919
本地运行需要编译选项"-lcrypt"加持,否则需重写to_string()函数;
相关文章推荐
- iOS Xcode工程目录的 folder 和 group的区别(链接)
- sublime text 2 快捷键 reindent 设置
- 熟悉一下GO的AES加密库
- OC语言中的便利初始化函数和便利构造器
- mybatis错误Invalid bound statement (not found) 的解决办法
- ps学习教程
- sql语法(一)
- 退火算法解决tsp问题
- Java泛型的类型擦除 http://blog.csdn.net/hust_is_lcd/article/details/7875386
- awk 处理
- 点击返回键退出popupwindow的方法
- 卷积神经网络用于视觉识别Convolutional Neural Networks for Visual Recognition
- 2016年3月
- Laravel 初学者的经验之谈
- 一个算法博客
- 应用间跳转问题
- Doxygen学习记录
- inputn函数与input函数的区别
- ionic 双击主页退出
- Unity如何在Editor下执行协程(coroutine)