首页 > 其他分享 >UESTC 1273 God Qing's circuital law

UESTC 1273 God Qing's circuital law

时间:2022-11-09 20:06:04浏览次数:44  
标签:Life Qing God Winner every girl 1273


Description



As we all know,God Qing is a very powerful ACMer. She very like junior sister apprentice,but in UESTC-ACM team,there is no junior sister apprentice,we can use a mathematical formula to express it.




But God Qing is a life winner , she has many beautiful girls,every girl has its BeautifulValue V ,and he want to take the most beautiful girl among all girls. For every girl,if God Qing chooses her,she can get a value called Life-Winner Point. We can use a mathematical formula to express it.


LifeWinnerPoint = HandsomeValue * BeautifulValue

When other people who come from UESTC-ACM team(such as Liao772002,Final-Pan,Final-Zhu and so on) know God Qing want to choose the most beautiful girl,they can't stand it! ,They also want a girl,for every person,he/she has its own HandsomeValue P. But God Qing wants to make her Life-Winner Point most,so she wants you to tell her there are how many ways can GodQing get the most Life-Winner Point.

In general. Thre are N competitors come from UESTC-ACM team(God Qing's ID is always 1) and N Girls, for every competitor,he/she has a HandsomeValue P[i] , for every girl , she has a BeatuifulValue V[i],every competitor can only choose a girl,and every girl can be only chose once. you should calculate there are how many ways that make GodQing get the most Life-Winner Point. (God Qing’s Life-Winner Point strictly greater than any other competitors).

Because the answer can be very large,you only need to print the answer modulo 10^9 + 7.


Input



Line 1: an integet N(the number of competitors and girls).

Line 2: N numbers p[i](the HandsomeValue of every competitor)

Line 3: N numbers v[i](the BeautifulValue of every girl).

1 <= N <= 100, 1 <= p[i] <= 10^6 , 1 <= v[i] <= 106.


Output



the number of ways that GodQing can get the most Life-Winner Point.


Sample Input

4 
5 8 4 8
19 40 25 20


Sample Output



2


Hint



Valid assignment #1: (5,40), (8,19), (4,25), (8,20).

Valid assignment #2: (5,40), (8,20), (4,25), (8,19).

In assignment #1, the Life-Winner Point of God Qing is 5 x 40 = 200. The other three units have Life-Winner Point 8 x 19 = 152, 4 x 25 = 100, and 8 x 20 = 160. This is a valid assignment because the number 200 is strictly greater than each of the numbers 152, 100, and 160.


这题第一眼还以为是二分图匹配什么的,结果想了半天也没想法。

后来突然间就想到了,这其实就是个暴力枚举。

简单来说,先把除了godqing以为的人从大到小排,所有女生从小到大排,

对于godqing来说,枚举所有的女生和他组合,对于每个组合来说

统计最大的人能选的数量,然后在统计第二大的,在算进答案里的时候要减去被第一大的人选过的那1个

之后的同理,这样就能算出所有的组合了。

#include<iostream>  
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<string>
#include<functional>
using namespace std;
typedef long long LL;
const int maxn = 1e5 + 2;
const int base = 1e9 + 7;
int T, n;
LL a[maxn], b[maxn], ans;

int main(){
//scanf("%d", &T);
while (~scanf("%d", &n))
{
for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
for (int i = 0; i < n; i++) scanf("%lld", &b[i]);
sort(a + 1, a + n, greater<int>()); sort(b, b + n);
ans = 0;
for (int i = 0; i < n; i++)
{
LL now = a[0] * b[i], res = 1, cnt = 0;
for (int j = 1, k = 0; j < n; j++)
{
while (k < n)
{
if (k == i) k++;
if (k < n&&a[j] * b[k] < now) { cnt++; k++; }
else break;
}
(res *= cnt--) %= base;
}
(ans += res) %= base;
}
printf("%lld\n", ans);
}
return 0;
}





标签:Life,Qing,God,Winner,every,girl,1273
From: https://blog.51cto.com/u_15870896/5838689

相关文章

  • mongodb添加删除节点及仲裁节点
    温馨提示:此mongodb版本为5.0.11,并注意,如果要删除节点,可以直接删除,添加节点前要先删除仲裁节点。rs.remove("192.168.0.180:27017");  (移除节点,如果移除仲裁节点一直卡......
  • Qing_HeDeMacBookAIr食用指北
    为啥都写这个。本来想卷题的但是看到\(\text{SMTwy}\)博客里一句话:“我本来感觉没有必要,但是\(\text{xxx}\)跟我说:要给你来个\(\text{360、2345}\)大礼包咋整”......
  • 【详细教程】一文参透MongoDB聚合查询
    MongoDB聚合查询什么是聚合查询聚合操作主要用于处理数据并返回计算结果。聚合操作将来自多个文档的值组合在一起,按条件分组后,再进行一系列操作(如求和、平均值、最大值、最......
  • linux安装mongodb 并且远程连接
    一、引言​​MongoDB​​是一个由C++语言编写的基于分布式文件存储的数据库,MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关......
  • mongodb基本操作合集
    创建管理员账号useadmindb.createUser({user:"root",pwd:"xxxxxx",roles:[{role:"root",db:"admin"}]})其他库创建账号......
  • Window环境下,安装MongoDB
    一、下载MongoDB官网下载地址:https://www.mongodb.com/try/download/community,选择MongoDB版本,平台为Windows,本文选择的安装包格式为msi:二、安装下载完成后,双击下载的m......
  • mongodb踩坑
    mongo中的日期,在显示上,会比我们正常的时间少8h。如果向mongo中插入数据,会少8h如果从mongo中查出数据,那么在idea中会是正常的;而如果是在datagrip/navicat中查,那么显示的时......
  • nginx 代理mongodb redis 配置
    worker_processes1;events{worker_connections1024;}stream{ upstreamapp-ssh{ server192.168.25.130:22; } upstreamapp-redis{ serve......
  • Windows安装Mongodb
    Windows安装Mongodb官方文档:https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-windows-unattended/目前MongoDB官网已经不支持32位安装包的下载,由......
  • mongodb 分片键的特点及分片原则
    mongodb分片键的特点,选择条件及分片原则1、集群cluster:包含多个分片分片shard:包含多个chunk块chunk:包含多个文档文档doc:包含shardkey的一行数据片键shardkey:文档......