解题关键:多项式除法的模拟。

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<iostream>//解法有些问题,应该用链表解,因为题目数据是整形范围
#include<cmath>
#define maxn 1000006
using namespace std;
typedef long long ll;
int maxa=-,maxb=-;
double a[maxn],b[maxn],c[maxn];
int clearzero(double *a,int ma){
int cnt=;
for(int i=ma;i>=;i--){
if(fabs(a[i])>=0.05) cnt++;
}
return cnt;
}
void output(int cnt,double *a,int ma){
if(cnt==){
printf("0 0 0.0");
}else{
printf("%d",cnt);
for(int i=ma;i>=;i--){
if(fabs(a[i])>=0.05) printf(" %d %.1lf",i,a[i]);
}
}
}
int main(){
int n,m,t1;
double t2;
cin>>n;
for(int i=;i<n;i++){
cin>>t1>>t2;
a[t1]=t2;
maxa=max(maxa,t1);
}
cin>>m;
for(int i=;i<m;i++){
cin>>t1>>t2;
b[t1]=t2;
maxb=max(maxb,t1);
}
for(int i=maxa;i>=maxb;i--){
c[i-maxb]=a[i]/b[maxb];
for(int j=maxb;j>=;j--){
a[j+i-maxb]-=c[i-maxb]*b[j];
}
} int cnt1,cnt2;
cnt1=clearzero(c,maxa-maxb);//商
cnt2=clearzero(a,maxb);//余数 output(cnt1,c,maxa-maxb);
printf("\n");
output(cnt2,a,maxb); return ;
}

最新文章

  1. Warning: strftime(): It is not safe to rely on the system&#39;s timezone settings.
  2. mysql 数据库连接超时的问题 autoReconnect=true
  3. JSTL标签库
  4. MFC 中控件的启用与禁用
  5. NHibernate分页
  6. C# 中 datagridview 绑定BindingList类型和更新
  7. CentOS忘记root密码的解决方法
  8. Python入门 学习笔记 (一)
  9. 利用boost做string到wstring转换,以及字符集转换 - Error - C++博客
  10. ORA-31626:作业不存在 ORA-31633:无法创建主表&quot;XXX.SYS_IMPORT_FULL_05&quot;
  11. dephi中单击鼠标拖动窗口(使用WM_SYSCOMMAND)
  12. Spring Boot属性文件配置文档(全部)
  13. JDK设计模式之——责任链(Filter)
  14. Javascript数组系列三之迭代方法2
  15. 解决Oracle登录极慢的问题
  16. [luogu4201][bzoj1063]设计路线【树形DP】
  17. 在 Python 中使用 in_memory 工作空间
  18. [iOS] UICollectionView实现图片水平滚动
  19. 在AbpZero中hangfire后台作业的使用——开启hangfire
  20. Cardano(ADA), EOS, RChain(RHOC), Aeternity(AE) 都是极其好的币

热门文章

  1. python3中的unicode_escape
  2. 用echarts绘制中国地图
  3. java快捷键大全
  4. Linux_服务器_09_新虚拟机下linux网络配置
  5. LeetCode OJ:Invert Binary Tree(反转二叉树)
  6. centos 6 &#160;简单安装mysql
  7. WinForm判断程序是否已经在运行,且只允许运行一个实例
  8. Unity3D教程:制作与载入AssetBundle
  9. bzoj 5016 一个简单的询问
  10. HihoCoder1070 区间最小值(简单线段树)