Solution

首先这个矩阵, 很明显的就是Vandermonde矩阵. 我们有公式:

\[|F_n| = \prod_{1 \le j < i \le n} (a_i - a_j)
\]

套圈的半径, 显然就是最小圆覆盖问题.

考虑到数据范围比较大, 我们直接做肯定是不行的. 这时候就涉及到一个神奇的东西:

我们知道假如行列式的某两行相同, 则该行列式的值为\(0\). 考虑这道题, 我们发现它生成数据的方式非常奇怪, 假设生成\(x\)组询问, 则所有询问两两不相同的概率为

\[\prod_{k = n}^{n - x + 1} \frac k n
\]

这个概率会迅速地下降, 因此期望不需要太多的次数, 行列式的值就会变为\(0\)...

真是有意思...

#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <algorithm> using namespace std;
namespace Zeonfai
{
inline int getInt()
{
int a = 0, sgn = 1; char c;
while (! isdigit(c = getchar())) if (c == '-') sgn *= -1;
while (isdigit(c)) a = a * 10 + c - '0', c = getchar();
return a * sgn;
}
}
const int N = (int)1e5, M = (int)1e5, MOD = (int)1e9 + 7;
struct point
{
double x, y;
inline point friend operator -(const point &a, const point &b) { point res; res.x = a.x - b.x; res.y = a.y - b.y; return res; }
inline double friend operator *(const point &a, const point &b) { return a.x * b.y - a.y * b.x; }
}p[N + 1];
double r[M + 1];
int L[M + 1], R[M + 1];
inline double sqr(double a) { return a * a; }
inline double getDistance(point a, point b) { return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y)); }
inline point getCentre(point a, point b, point c)
{
point ret;
double a1 = b.x - a.x, b1 = b.y - a.y, c1 = (a1 * a1 + b1 * b1) / 2;
double a2 = c.x - a.x, b2 = c.y - a.y, c2 = (a2 * a2 + b2 * b2) / 2;
double d = a1 * b2 - a2 * b1;
ret.x = a.x + (c1 * b2 - c2 * b1) / d;
ret.y = a.y + (a1 * c2 - a2 * c1) / d;
return ret;
}
int main()
{ #ifndef ONLINE_JUDGE freopen("circle.in", "r", stdin);
freopen("circle.out", "w", stdout); #endif using namespace Zeonfai;
int n = getInt();
for (int i = 1; i <= n; ++ i) p[i].x = getInt(), p[i].y = getInt();
int m = getInt();
int ans = 1;
for (int i = 1; i <= m; ++ i)
{
L[i] = getInt(), R[i] = getInt();
if (! ans) { printf("%lld\n", (long long)L[i] * R[i]); continue; }
point cen = p[L[i]]; r[i] = 0;
for (int j = L[i] + 1; j <= R[i]; ++ j) if (getDistance(p[j], cen) > r[i])
{
cen = p[j]; r[i] = 0;
for (int k = L[i]; k < j; ++ k) if (getDistance(p[k], cen) > r[i])
{
cen.x = (p[j].x + p[k].x) / 2; cen.y = (p[j].y + p[k].y) / 2;
r[i] = getDistance(p[j], cen);
for (int l = L[i]; l < k; ++ l) if (getDistance(p[l], cen) > r[i])
{
if ((p[k] - p[j]) * (p[l] - p[j]) == 0)
{
cen.x = (p[j].x + p[l].x) / 2; cen.y = (p[j].y + p[l].y) / 2;
r[i] = getDistance(p[l], cen);
}
else cen = getCentre(p[j], p[k], p[l]), r[i] = getDistance(p[l], cen);
}
}
}
for (int j = 1; j < i; ++ j) ans = (long long)ans * ((long long)r[i] - (long long)r[j] + MOD) % MOD;
printf("%lld\n", (long long)ans + L[i] * R[i]);
}

NOI模拟题6 Problem C: Circle的更多相关文章

  1. NOI模拟题1 Problem A: sub

    题面 Sample Input 5 7 2 -1 -3 1 1 1 2 1 3 3 4 3 5 2 1 3 0 2 1 2 1 2 1 1 -3 2 Sample Output 2 4 5 2 HIN ...

  2. NOI模拟题5 Problem A: 开场题

    Solution 注意到\(\gcd\)具有结合律: \[ \gcd(a, b, c) = \gcd(a, \gcd(b, c)) \] 因此我们从后往前, 对于每个位置\(L\), 找到每一段不同的 ...

  3. NOI模拟题4 Problem C: 填格子(board)

    Solution 首先我们要有敏锐的直觉: 我们将每一列中不选哪种颜色看作是一个序列, 则我们发现这个序列要求相邻两位的颜色不同. 我们还发现, 一个这样的序列对应两种不同的合法的棋盘, 因此统计合法 ...

  4. NOI模拟题4 Problem B: 小狐狸(fox)

    Solution 考虑分开统计朝向每一个方向的所有狐狸对答案的贡献. 比如说以向右为例, 我们用箭标表示每一只狐狸的方向, 用\('\)表示当前一步移动之前的每一只狐狸的位置. \[ \begin{a ...

  5. NOI模拟题4 Problem A: 生成树(mst)

    Solution 我们考虑答案的表达式: \[ ans = \sqrt{\frac{\sum_{i = 1}^{n - 1} (w_i - \overline{w})^2}{n - 1}} \] 其中 ...

  6. 花海漫步 NOI模拟题

    题目好像难以看懂? 题目大意 给出一个字符串\(S\),统计满足以下条件的\((i,j,p,q)\)的数量. \(i \leq j, p \leq q\) \(S[i..j],S[p..q]\)是回文 ...

  7. 神奇的矩阵 NOI模拟题

    神奇的矩阵 题目大意 有一个矩阵\(A\),第一行是给出的,接下来第\(x\)行,第\(y\)个元素的值为数字\(A_{x-1,y}\)在\(\{A_{x-1,1},A_{x-1,2},A_{x-1, ...

  8. Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem K. UTF-8 Decoder 模拟题

    Problem K. UTF-8 Decoder 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c702 ...

  9. 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem I. Interest Targeting 模拟题

    Problem I. Interest Targeting 题目连接: http://codeforces.com/gym/100714 Description A unique display ad ...

随机推荐

  1. springboot(七):springboot+mybatis多数据源最简解决方案

    说起多数据源,一般都来解决那些问题呢,主从模式或者业务比较复杂需要连接不同的分库来支持业务.我们项目是后者的模式,网上找了很多,大都是根据jpa来做多数据源解决方案,要不就是老的spring多数据源解 ...

  2. Oracle数据库迁移--->从Windows到Linux

    I did a practice to migrate the oracle database from windows to linux operation system. The followin ...

  3. CSU-2172 买一送一

    CSU-2172 买一送一 Description ICPCCamp 有 n 个商店,用 1, 2, -, n 编号.对于任意 i > 1,有从商店 \(p_i\) 到 i 的单向道路. 同时, ...

  4. Python面向对象之常用的特殊方法(5)

    Python面向对象里面有很多特殊方法,例如__init__(构造方法),__del__(析构方法),这些方法对于面向对象编程非常重要,下面列出一些常用的特殊方法 (1)__call__ class ...

  5. 课堂笔记III

  6. maven学习(十三)——eclipse整合maven插件

    一.安装Maven插件 下载下来的maven插件如下图所示:,插件存放的路径是:E:/MavenProject/Maven2EclipsePlugin

  7. C#知识点<4>

    1\C# 运算符重载 您可以重定义或重载 C# 中内置的运算符.因此,程序员也可以使用用户自定义类型的运算符.重载运算符是具有特殊名称的函数,是通过关键字 operator 后跟运算符的符号来定义的. ...

  8. ZOJ 3362 Beer Problem(SPFA费用流应用)

    Beer Problem Time Limit: 2 Seconds      Memory Limit: 32768 KB Everyone knows that World Finals of A ...

  9. bzoj2553【beijing2011】禁忌

    题意:http://www.lydsy.com/JudgeOnline/problem.php?id=2553 sol  :puts("nan"); (逃~ ac自动机+矩阵快速幂 ...

  10. Python Spider

    一.网络爬虫 网络爬虫又被称为网络蜘蛛(