当前位置:网站首页>PAT1009
PAT1009
2022-08-09 11:09:00 【AlanLiu6】
https://pintia.cn/problem-sets/994805342720868352/problems/994805509540921344
#include<cstdio>
double num[1005],ans[2005];
int main()
{
int k;
scanf("%d",&k);
while(k--)
{
int x;
double y;
scanf("%d %lf",&x,&y);
num[x] = y;
}
scanf("%d",&k);
while(k--)
{
int x;
double y;
scanf("%d %lf",&x,&y);
for(int i = 0;i < 1005;i++)
{
ans[x+i] += num[i]*y;
}
}
int len = 0;
for(int i = 0;i < 2005;i++)
if(ans[i] != 0.0) len++;
printf("%d",len);
for(int i = 2005;i >=0 ;i--)
{
if(ans[i] != 0.0) printf(" %d %.1lf",i,ans[i]);
}
printf("\n");
return 0;
}
边栏推荐
猜你喜欢
随机推荐
The use of signal function (signal) in C language
x86异常处理与中断机制(2)中断向量表
性能测试(04)-表达式和业务关联-JDBC关联
PAT1010
es6的async函数
OC-块对象
golang 三种指针类型具体类型的指针、unsafe.Pointer、uintptr作用
MATLAB代码实现三次样条插值
获取指定年度所有周的工具类
【VIBE: Video Inference for Human Body Pose and Shape Estimation】论文阅读
Qt 国际化翻译
Tensorflow realize parameter adjustment of linear equations
1003 Emergency (25分)
fork创建多个子进程
es6对象迭代器iterator
日期工具类
fork creates multiple child processes
Julia常见符号意思
基于STM32F103移植FreeRTOS
Number theory knowledge