hdu1877-进制转换问题 vector容器
来源:互联网 发布:魔法王座数据查询 编辑:程序博客网 时间:2024/05/24 06:33
1877
A+B之后的值有可能超过int的范围,所以要用long long型
还要考虑当和为0是的情况,要输出0(题意为非负,那么就包括0)
#include<iostream> #include<string> #include<vector> using namespace std; int main() { int a,b,m; long long s; vector<int> vec; while (cin>>m && m!=0) { cin>>a>>b; s = a+b; vec.clear(); if (s==0)cout<<0; while (s) { vec.push_back(s%m); s/=m; } int i; for (i = vec.size()-1;i>=0;i--) { cout<<vec[i]; } cout<<endl; } return 0; }
0 0
- hdu1877-进制转换问题 vector容器
- hdu2031-进制转换问题 vector容器
- hdu1877
- HDU1877
- HDU1877
- 遍历vector容器的效率问题
- 遍历vector容器的效率问题
- STL容器vector的内存问题
- STL容器vector的内存问题
- STL容器vector的内存问题
- STL容器中的vector初始化问题
- 容器赋值 容器使用问题:vector subscript out of range
- vector 容器
- Vector容器
- vector容器
- Vector 容器
- vector容器
- vector容器
- Spring Boot Logback应用日志
- 字节流与字符流的区别
- ionic工程嵌入iOS Native工程
- POJ-3468 A Simple Problem with Integers(线段树模板题)
- Unity Shader Example 14 (平面切割图片 )
- hdu1877-进制转换问题 vector容器
- nginx配置参考1
- Far Relative’s Problem(贪心模拟)
- Android适配
- OpenLayers3入门篇-创建地图
- iOS-OC-图片水印,图片裁剪和屏幕截图
- keypress、keyup、keydown事件频繁执行优化
- poj1328Radar Installation
- mybatis如何防止sql注入