南阳理工OJ_题目541 最强DE 战斗力
2014-04-03 21:16
417 查看
好久没敲过ACM了,连一个大数相乘都写了好久,还有就是,刚开始不知道这题怎么写的,没有思路,有事数学的问题,自己又坑了,还是百度了一下才找到思路的...
#include <iostream> #include <string.h> using namespace std; void fun(char *a, int n, int len); int main() { int N; cin >> N; while(N--) { int t; char a[200] = {'1'}; int len; cin >> t; while(t >= 5) { len = strlen(a); fun(a, 3, len); t -= 3; } len = strlen(a); fun(a, t, len); int i = 190; while( a[i] == 0 ) i--; for(; i >= 0; i--) cout << a[i]; cout << endl; } } void fun(char *a, int n, int len) { int t = 0; int i; for(i = 0; i < len; i++) { t = (a[i]-'0') * n + t; a[i] = t % 10 + '0'; t = t / 10; } while(t != 0) { a[i] = t % 10 + '0'; t /= 10; i++; } }
相关文章推荐
- LeetCode之Regular Expression Matching
- 软件创意-----和普通话的那点事儿
- 学习 C# (1)
- ASP.NET 设置DropDownList选中项
- 栈的两种C++实现
- tar压缩与解压缩
- Android 中Touch(触屏)事件传递机制
- 有关统计单词频率的算法c语言实现
- 46
- The connection to adb is down, and a severe error has occured.
- spring与mybatis整合(基于配置文件)
- d3-bars
- Uva 580 - Critical Mass 解题报告(递推)
- ppst技术视频——eclipse 安装tomcat插件的方法
- 产生一个1-100长度为100不重复的数组
- 算法第四次作業
- JAVA中string.repalce()和string.replaceAll()有什么区别?
- 分享一个自动生成单据的存储过程
- 微信公众开放平台开发03---百度BAE上搭建属于自己的微信公众平台 -JAVA,微信公众开放平台部署到百度云中BASE2.0,进行调试,木有钱买云服务器的亲们试试
- 算法第四周作业