P1480 A/B Problem

题目描述

输入两个整数a,b,输出它们的商(a<=10^5000,b<=10^9)

输入输出格式

输入格式:

两行,第一行是被除数,第二行是除数。

输出格式:

一行,商的整数部分

输入输出样例

输入样例#1: 复制

10
2
输出样例#1: 复制

5
#include<iostream>
#include<cstring>
using namespace std;
int a[],b[],c[],d,i;
void init(int a[])
{
string s;
cin>>s;
a[]=s.length();
for(i=;i<=a[];i++)
a[i]=s[a[]-i]-'';
}
void numcpy(int p[],int q[],int det)
{
for(int i=;i<=p[];i++)
q[i+det-]=p[i];
q[]=p[]+det-;
}
int compare(int a[],int b[])
{
int i;
if(a[]>b[])
return ;
if(a[]<b[])
return -;
for(i=a[];i>;i--)
{
if(a[i]>b[i])
return ;
if(a[i]<b[i])
return -;
}
return ;
}
void jian(int a[],int b[])
{
int flag,i;
flag=compare(a,b);
if(flag==)
{
a[]=;
return;
}
if(flag==)
{
for(i=;i<=a[];i++)
{
if(a[i]<b[i])
{
a[i+]--;
a[i]+=;
}
a[i]-=b[i];
}
while(a[]>&&a[a[]]==)
a[]--; }
}
void chugao(int a[],int b[],int c[])
{
int i,tmp[];
c[]=a[]-b[]+;
for(int i=c[];i>;i--)
{
memset(tmp,,sizeof(tmp));
numcpy(b,tmp,i);
while(compare(a,tmp)>=)
{
c[i]++;
jian(a,tmp);
}
}
while(c[]>&&c[c[]]==)
c[]--;
}
void printf(int a[])
{
int i;
if(a[]==)
{
cout<<<<endl;
return;
}
for(int i=a[];i>;i--)
cout<<a[i];
cout<<endl;
return;
}
int main()
{
init(a);
init(b);
chugao(a,b,c);
printf(c);
//printf(a);
}

洛谷P1480 A/B Problem(高精除高精)的更多相关文章

  1. 洛谷——P1480 A/B Problem

    P1480 A/B Problem 题目描述 输入两个整数a,b,输出它们的商(a<=10^5000,b<=10^9) 输入输出格式 输入格式: 两行,第一行是被除数,第二行是除数. 输出 ...

  2. 洛谷 P1480 A/B Problem

    P1480 A/B Problem 题目描述 输入两个整数a,b,输出它们的商(a<=10^5000,b<=10^9) 输入输出格式 输入格式: 两行,第一行是被除数,第二行是除数. 输出 ...

  3. 洛谷1601 A+B Problem(高精) 解题报告

    洛谷1601 A+B Problem(高精) 本题地址:http://www.luogu.org/problem/show?pid=1601 题目背景 无 题目描述 高精度加法,x相当于a+b pro ...

  4. 洛谷1303 A*B Problem 解题报告

    洛谷1303 A*B Problem 本题地址:http://www.luogu.org/problem/show?pid=1303 题目描述 求两数的积. 输入输出格式 输入格式: 两个数 输出格式 ...

  5. 洛谷1001 A+B Problem

    洛谷1001 A+B Problem 本题地址:http://www.luogu.org/problem/show?pid=1001 题目描述 输入两个整数a,b,输出它们的和(|a|,|b|< ...

  6. 洛谷P1865 A % B Problem

    1.洛谷P1865 A % B Problem 题目背景 题目名称是吸引你点进来的 实际上该题还是很水的 题目描述 区间质数个数 输入输出格式 输入格式: 一行两个整数 询问次数n,范围m 接下来n行 ...

  7. 【题解】洛谷P2532 [AHOI2012]树屋阶梯(卡特兰数+高精)

    洛谷P2532:https://www.luogu.org/problemnew/show/P2532 思路 来自Sooke大佬的推导: https://www.luogu.org/blog/Sook ...

  8. 洛谷P1919 A*B problem 快速傅里叶变换模板 [FFT]

    题目传送门 A*B problem 题目描述 给出两个n位10进制整数x和y,你需要计算x*y. 输入输出格式 输入格式: 第一行一个正整数n. 第二行描述一个位数为n的正整数x. 第三行描述一个位数 ...

  9. 【洛谷P1303 A*B Problem】

    题目描述 求两数的积. 输入输出格式 输入格式: 两行,两个数. 输出格式: 积 输入输出样例 输入样例#1: 1 2 输出样例#1: 2 说明 每个数字不超过10^2000,需用高精 emm,显然本 ...

随机推荐

  1. 有關WCF一個自認爲比較經典的博客

    无废话WCF入门教程四[WCF的配置文件] (http://www.cnblogs.com/iamlilinfeng/archive/2012/10/02/2710224.html) -------- ...

  2. JavaUtil_06_HttpUtil_使用httpclient实现

    一.简介 使用 appache 的 httpclient 来实现的 二.源码 package com.ray.weixin.gz.util; import java.io.File; import j ...

  3. 【LeetCode】012. Integer to Roman

    Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...

  4. vs2015解决fopen、fscanf 要求替换为fopen_s、fscanf_s的办法

    在工程项目设置一下就行:项目属性 -- C/C++-- 预处理器 -- 预处理器定义,添加:_CRT_SECURE_NO_WARNINGS

  5. linux获取文件大小的函数

    C语言fstat()函数:由文件描述词取得文件状态 头文件:#include <sys/stat.h>   #include <unistd.h> 定义函数:int fstat ...

  6. shell入门-awk-2

    awk的条件操作符 ///显示第一段有root的行 [root@wangshaojun ~]# awk -F ':' '$1=="root"' 1.txtroot:x:0:0:ro ...

  7. shell入门-uniq去重复和tee重定向

    命令:uniq 选项:-c 显示重复数量 说明:去重复,不sort多个功能,显示几个重复 命令:tee 说明:重定向加上双重输出 [root@wangshaojun ~]# cat 2.txt1222 ...

  8. MS-SQL循环、随机数

    ---创建视图 create view myview as select re=rand() --自定义函数:取得指定范围的随机数 create function mydata( @a int, @b ...

  9. fabric自动化安装mysql-server

    1.创建文件auto_install_mysql.py vim auto_install_mysql.py --------------------------------------------&g ...

  10. [HDU1754]I Hate It线段树裸题

    http://acm.hdu.edu.cn/showproblem.php?pid=1754 解题关键:刚开始死活超时,最后发现竟然是ch,和t1.t2每次循环都定义的锅,以后养成建全局变量的习惯. ...