博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2019牛客暑期多校训练营(第一场) B Integration (数学)
阅读量:4664 次
发布时间:2019-06-09

本文共 2462 字,大约阅读时间需要 8 分钟。

链接:

来源:牛客网

Integration

时间限制:C/C++ 2秒,其他语言4秒
空间限制:C/C++ 524288K,其他语言1048576K
64bit IO Format: %lld
题目描述
Bobo knows that
0
1
1

  • x
    2

d

x
=
π
2
.
∫0∞11+x2 dx=π2.

Given n distinct positive integers

a
1
,
a
2
,
,
a
n
a1,a2,…,an, find the value of
1
π
0
1
n
i
=
1
(
a
2
i

  • x
    2
    )

d

x
.
1π∫0∞1∏i=1n(ai2+x2) dx.

It can be proved that the value is a rational number

p
q
pq.
Print the result as
(
p
q
1
)
mod
(
10
9

  • 7
    )
    (p⋅q−1)mod(109+7).
    输入描述:
    The input consists of several test cases and is terminated by end-of-file.

The first line of each test case contains an integer n.

The second line contains n integers
a
1
,
a
2
,
,
a
n
a1,a2,…,an.

  • 1
    n
    10
    3
    1≤n≤103
  • 1
    a
    i
    10
    9
    1≤ai≤109
  • {
    a
    1
    ,
    a
    2
    ,
    ,
    a
    n
    }
    {a1,a2,…,an} are distinct.
  • The sum of
    n
    2
    n2 does not exceed
    10
    7
  1. 输出描述:
    For each test case, print an integer which denotes the result.
    示例1
    输入
    复制
    1
    1
    1
    2
    2
    1 2
    输出
    复制
    500000004
    250000002
    83333334

题意:

思路:

1578720-20190718194036710-1377160531.png

事实上我并不会上面的处理,真正积分的话要用裂项相消来出来。

但是有强大的自动积分软件啊:

1578720-20190718194142835-718179039.png

输入一个n=5的 情况,就可以看出规律。

细节见代码:

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define ALL(x) (x).begin(), (x).end()#define rt return#define dll(x) scanf("%I64d",&x)#define xll(x) printf("%I64d\n",x)#define sz(a) int(a.size())#define all(a) a.begin(), a.end()#define rep(i,x,n) for(int i=x;i
#define pll pair
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)#define MS0(X) memset((X), 0, sizeof((X)))#define MSC0(X) memset((X), '\0', sizeof((X)))#define pb push_back#define mp make_pair#define fi first#define se second#define eps 1e-6#define gg(x) getInt(&x)#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<
> n) { repd(i, 1, n) { cin >> a[i]; } ll ans = 0ll; repd(i, 1, n) { ll sum = 1ll; repd(j, 1, n) { if (i != j) sum = sum * ((a[j] * a[j] - a[i] * a[i]) % mod) % mod; } // sum = (sum + mod) % mod; sum = (sum * a[i]) % mod; sum = (sum * 2ll) % mod; sum = powmod(sum, mod - 2ll, mod); ans = (ans + sum) % mod; } ans = (ans + mod) % mod; cout << ans << endl; } return 0;}inline void getInt(int* p) { char ch; do { ch = getchar(); } while (ch == ' ' || ch == '\n'); if (ch == '-') { *p = -(getchar() - '0'); while ((ch = getchar()) >= '0' && ch <= '9') { *p = *p * 10 - ch + '0'; } } else { *p = ch - '0'; while ((ch = getchar()) >= '0' && ch <= '9') { *p = *p * 10 + ch - '0'; } }}

转载于:https://www.cnblogs.com/qieqiemin/p/11209576.html

你可能感兴趣的文章
哈佛管理学———气质的培养
查看>>
es 修改拼音分词器源码实现汉字/拼音/简拼混合搜索时同音字不匹配
查看>>
Go学习笔记(二):编写 HelloWorld 程序
查看>>
视觉slam十四讲课后习题ch3-7
查看>>
adb_亮屏
查看>>
Windows默认字符集_查询
查看>>
深度学习基础1--神经网络
查看>>
深度学习基础2--神经网络参数的反向传播算法
查看>>
洛谷 P1560 [USACO5.2]蜗牛的旅行Snail Trails
查看>>
MeayunDB-高性能分布式内存数据库
查看>>
反射 模板赋值
查看>>
【读书】领导力的5个层次-认同
查看>>
Tomcat创建HTTPS访问,java访问https
查看>>
Matlab实现IIR数字滤波器设计
查看>>
java常见异常
查看>>
手动添加PopMenu出现的问题
查看>>
Linux 远程桌面 访问 WIndows
查看>>
SQLServer存储过程自制数据字典
查看>>
TCP的粘包问题
查看>>
树上有十只鸟,开枪打死一只,还剩几只?
查看>>