TOJ4439微积分――曲线积分(数学,模拟)
传送门:点我
格林公式
P,Q为关于x,y的函数。
现在为了方便起见,现给出x的积分上限1,积分下限0, y的积分上限x,积分下限0。
P只是关于Y的函数,Q只是关于X的函数。
输入
开始输入为测试组数n。每一组的开始输入Q的项数q和Q关于X的系数以及指数。接下来是P的多项式的项数p和P的关于Y的系数以及指数。
p<= 100, q <= 100。注意:指数是正整数,系数不为 0。
输出
每一组输出为一行,保留两位小数。
样例输入
2
1
2 2
1
3 3
2
1 1
2 2
2
1 1
2 2
样例输出
0.58
0.67
思路:
本质是套公式计算算偏导数
例如样例中第一个数据Q=2x^2,P=3y^3.
代入公式计算的就是

中间是4x-9y^2的原因:根据格林公式中,对Q求关于x的偏导,对P求对于y的偏导,两式相减得到4x-9y^2。
计算过程:


7/12 写成小数保留2位就是0.58
因此就模拟求导积分的过程就行了,因为上界下届都给定了,我套了个map存指数对应的系数(注意系数要用double)
代码:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <bitset>
#define LL long long
#define pb push_back
#define mk make_pair
#define pill pair<int, int>
#define mst(a, b) memset(a, b, sizeof a)
#define REP(i, x, n) for(int i = x; i <= n; ++i)
#define pi acos(-1.0)
#define Max_N 1001
#define inf 0x3f3f3f3f
#define N 1001
#define ll long long
using namespace std;
int main(){
int _;
for(scanf("%d",&_);_--;){
int n;scanf("%d",&n);
map<int,double>mp;
while(n--){
int x;double a;
scanf("%lf%d",&a,&x);
a*=x;
x-=;//求导
mp[x+] += a;//积分之后乘以x
}
int m;
scanf("%d",&m);
while(m--){
int x;double a;
scanf("%lf%d",&a,&x);
mp[x] -= a;
}
double ans = ;
map<int,double>::iterator it = mp.begin();
for(;it != mp.end() ;it++){
double xi = it->second;
int zhi = it->first;
ans += xi/(1.0*(zhi+));
}
printf("%.2lf\n",ans);
}
}
/*
2
2
1 1
2 2
2
1 1
2 2
*/
TOJ4439微积分――曲线积分(数学,模拟)的更多相关文章
- [再寄小读者之数学篇](2014-04-01 from 2103471050@qq.com 曲线积分)
求 $\int_\vGa y^2\rd s$, 其中 $\vGa$ 由 $\dps{\sedd{\ba{rl} x^2+y^2+z^2&=a^2\\ x+z&=a \ea}}$ 决定. ...
- 2017 Multi-University Training Contest - Team 9 1004&&HDU 6164 Dying Light【数学+模拟】
Dying Light Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Tot ...
- zzulioj--1825-- 会长爱数学(模拟)
1825: 会长爱数学 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 6 Solved: 2 SubmitStatusWeb Board Descr ...
- 数学&模拟:随机化-矩阵随机化
BZOJ2396 给出三个行数和列数均为N的矩阵A.B.C,判断A*B=C是否成立 随机生成一个N乘1的矩阵R 然后判断A*B*R是否等于C*R,而前者相当于A*(B*R) 与后者一样都可以在O(N2 ...
- 2017ACM暑期多校联合训练 - Team 2 1008 HDU 6052 To my boyfriend (数学 模拟)
题目链接 Problem Description Dear Liao I never forget the moment I met with you. You carefully asked me: ...
- HDU 4498 Function Curve (分段,算曲线积分)
Function Curve Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)To ...
- CF 990A. Commentary Boxes【数学/模拟】
[链接]:CF [题意]:对于一个数n,每次加一的代价是a,每次减一的代价是b,求被m整除时的最小代价. [分析]:分情况讨论,自己多举几个栗子. [代码]: #include<cstdio&g ...
- CF 450E Jzzhu and Apples 数学+模拟
E. Jzzhu and Apples time limit per test 1 second memory limit per test 256 megabytes input standard ...
- [CSP-S模拟测试]:砍树(数学+模拟)
题目传送门(内部题1) 输入格式 第一行两个整数$n$,$k$,代表树苗的数量和最大看书的总长度.第二行n个整数$a_i$,代表林先森希望每棵树苗的最终高度. 输出格式 一行一个整数,代表最大可能的d ...
随机推荐
- ssm学习的第一个demo---crm(1)
这是一个普通的CRM项目 (第一步规划好项目设计路线:导入jar包→配置sqlMapConfig.xml(空文件)→配置applicationContext.xml →配置springMVC.xml→ ...
- 登录之md5加密
语句: password = hex_md5(password); 引入js文件: md5.js: /* * A JavaScript implementation of the RSA Data S ...
- JVM虚拟机宕机_java.lang.OutOfMemoryError: unable to create new native thread
原因:当前用户的系统最最大程序数数已达到最大值,使用ulimit -u可以看到是1024 解决办法:在当前用户下使用ulimit -u 65535 然后再执行jsp,一切ok 功能说明:控 ...
- Spring cloud info信息显示
父工程添加配置如下 <build> <finalName>microservicecloud</finalName> <resources> <r ...
- hive,分桶,内外部表,分区
简单的word-count操作: [root@master test-map]# head -10 The_Man_of_Property.txt #先看看数据Preface“The Forsy ...
- AJAX之发送GET请求
用jquery发送get请求 function AjaxSubmit1() { $.ajax({ //用jQuery发送 url: '/app04/ajax1/', type: 'GET', data ...
- Turn the Rectangles 1008B
output standard output There are nn rectangles in a row. You can either turn each rectangle by 9090 ...
- HashSet和LinkedHashSet解析
一.简介 1.Set概念 Set可以理解为集合,非常类似数据概念中的集合,集合三大特征:1.确定性:2.互异性:3.无序性,因此Set实现类也有类似的特征. 2.HashSet HashSet继承自A ...
- jsp开发环境搭建(windows64位)
有些东西当时学和用的时候很熟练,但如果时间久了不用了,再次遇到的时候,也会很生疏,现在对一般的jsp网站开发环境的搭建做一个小结,以备以后不时之需,作为参考手册用. 一.java环境搭建 1.下载jd ...
- [Sphinx]全文索引Sphinx的使用配置
-------------------------------------------------------------------------------------- 搜索分为两种: 1. 对结 ...