【高精度】高精度数除以低精度数I
问题 G: 【高精度】高精度数除以低精度数I
时间限制: 1 Sec 内存限制: 512 MB
提交: 173 解决: 71
[提交] [状态] [讨论版] [命题人:]
题目描述
输入
输出
样例输入
20
5
样例输出
4
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string Multiply(string s,int x){
reverse(s.begin(),s.end());
int cmp=;
for(int i=;i<s.size();i++){
cmp=(s[i]-'')*x+cmp;
s[i]=(cmp%+'');
cmp/=;
}
while(cmp){
s+=(cmp%+'');
cmp/=;
}
reverse(s.begin(),s.end());
return s;
}
string Except(string s,int x){
int cmp=,ok=;
string ans="";
for(int i=;i<s.size();i++){
cmp=(cmp*+s[i]-'');
if(cmp>=x){
ok=;
ans+=(cmp/x+'');
cmp%=x;
}
else if(ok==)ans+='';
}
return ans.empty()?"":ans;
}
int main(int argc, char *argv[]) {
string a;
int b;
cin>>a>>b;
cout<<Except(a,b)<<endl;
}
【高精度】高精度数除以低精度数I的更多相关文章
- Single Round Math sdut3260高精度除以低精度
做高精度除法,从高位开始除..高位除剩下的我们就*10扔给低一位处理,最终余数是在最低位取模得到的 高精除以高精,我们可以这么做,让除数在后面补零,刚好小于被除数,作若干次减法,减的次数加到商里面 然 ...
- 数论 - 高精度Fibonacci数 --- UVa 10183 : How Many Fibs ?
How many Fibs? Description Recall the definition of the Fibonacci numbers: f1 := 1 f2 := 2 fn := f n ...
- HDU 1023 Traning Problem (2) 高精度卡特兰数
Train Problem II Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Sub ...
- HDU 3723 Delta Wave (高精度+calelan数)
题意:给定一个图,问你只能向上向下,或者平着走,有多少种方法可以走到最后一个格. 析:首先先考虑,如果没有平的情况就是calelan数了,现在有平的情况,那么就枚举呗,因为数很大,所以要用高精度. 答 ...
- 第三周PTA笔记 回文数+A-B(大数减法)+高精度除法+数楼梯(大数加法)
回文数 对于一个自然数n,若将n的各位数字反向排列所得的数n1与n相等,则称n为回文数,例如2332. 若给定一个N( 2<=N<=16)进制数M(M的长度在一百位以内),如果M不是回文数 ...
- Luogu1655 小朋友的球 (组合数学,第二类斯特林数,高精)
我bingoyes再高精用STL就饿死,死外边! string真的爽... 斯特林数模板题:\(S(n,m) = S(n-1,m-1)+S(n-1,m)*n\) #include <iostre ...
- 【题解】洛谷P1066 [NOIP2006TG] 2^k进制数(复杂高精+组合推导)
洛谷P1066:https://www.luogu.org/problemnew/show/P1066 思路 挺难的一道题 也很复杂 满足题目要求的种数是两类组合数之和 r的最多位数m为 w/k(当w ...
- Luogu3904 三只小猪 (组合数学,第二类斯特林数,高精)
即使\(n<=50\),斯特林数也会爆long long. #include <iostream> #include <cstdio> #include <cstr ...
- 中石油-高精度除法-java版
问题 G: [高精度]高精度数除以低精度数I 时间限制: 1 Sec 内存限制: 512 MB提交: 19 解决: 15[提交][状态][讨论版] 题目描述 修罗王聚集了庞大的暗元素以施展隐匿魔法 ...
随机推荐
- 【Pascal's Triangle】cpp
题目: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,R ...
- 油田(DFS)
//DFS:油田问题 #include <iostream> using namespace std; ][]; int n,m; //一个网格的8个方向 ][] = {{-,-},{-, ...
- 【转载】法线贴图Nomal mapping 原理
法线贴图多用在CG动画的渲染以及游戏画面的制作上,将具有高细节的模型通过映射烘焙出法线贴图,贴在低端模型的法线贴图通道上,使之拥有法线贴图的渲染效果,却可以大大降低渲染时需要的面数和计算内容,从而达到 ...
- CSU-2110 Keeping Cool
题目链接 http://acm.csu.edu.cn:20080/csuoj/problemset/problem?pid=2110 题目 Description Kevin has just got ...
- shell之一些测试脚本
比较文件有无修改,通过修改时间判别 # !/bin/bash dir=$ for file in `ls $dir` do if [ -d $dir/$file ] then echo $file i ...
- GCC特性之__init修饰解析 - kasalyn的专栏 - 博客频道 - CSDN.NET
, GCC特性之__init修饰解析 - kasalyn的专栏 - 博客频道 - CSDN.NET.MathJax_Hover_Frame {border-radius: .25em; -webkit ...
- CodeForces D. Concatenated Multiples
http://codeforces.com/contest/1029/problem/D You are given an array aa, consisting of nn positive in ...
- linux下源代码分析和阅读工具比较
Windows下的源码阅读工具Souce Insight凭借着其易用性和多种编程语言的支持,无疑是这个领域的“带头大哥”.Linux/UNIX环境下呢?似乎仍然是处于百花齐放,各有千秋的春秋战国时代, ...
- Codeforces Round #355 (Div. 2) C 预处理
C. Vanya and Label time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Numpy基本数据结构
Numpy数组是一个多维数组对象,称为ndarray.其由两部分组成: 1 实际的数据 2 描述这些数据的元数据 一 ndarray的方法 # 多维数组ndarray import numpy as ...