P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e18;
const int MAXN = 1e3 + 5;
const int maxm = 1e6 + 10;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int dx[] = {-1,1,0,0,1,1,-1,-1};
const int dy[] = {0,0,1,-1,1,-1,1,-1};
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int maxn = 1e6;
double s[maxn], p[maxn];
set st;
struct node
{
double x,y;
}a[maxn];
bool cmp(node a, node b)
{
return a.x<b.x;
}
int main()
{
int t,n;
scanf("%d",&t);
while(t--)
{
int f=1;
double Max = 0;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%lf%lf",&a[i].x,&a[i].y);
}
sort(a,a+n,cmp);
for(int i=1;i<n;i++){
if(a[i].x-a[i-1].x==0) {f=0;break;}
double tmp = (double)fabs(a[i].y-a[i-1].y) / fabs(a[i].x-a[i-1].x);
Max = max(Max,tmp);
}
f?printf("%.6lf
",Max):puts("-1");
}
}
[第二题:贝壳找房户外拓展(简单)](https://nanti.jisuanke.com/t/27117)
【分析】:模拟。主要是题意的理解。(ps:数据较大貌似用线段树维护矩阵(QAQ数据结构苦手
【代码】:
include
include
include
include
include
include
include
include
include
include
include
include
include
include
include
include<assert.h>
include
include
define debug() puts("++++")
define gcd(a,b) __gcd(a,b)
define lson l,m,rt<<1
define rson m+1,r,rt<<1|1
define fi first
define se second
define pb push_back
define sqr(x) ((x)*(x))
define ms(a,b) memset(a,b,sizeof(a))
define sz size()
define be begin()
define pu push_up
define pd push_down
define cl clear()
define lowbit(x) -x&x
define all 1,n,1
define rep(i,n,x) for(int i=(x); i<(n); i++)
define in freopen("in.in","r",stdin)
define out freopen("out.out","w",stdout)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e18;
const int MAXN = 1e3 + 5;
const int maxm = 1e6 + 10;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int dx[] = {-1,1,0,0,1,1,-1,-1};
const int dy[] = {0,0,1,-1,1,-1,1,-1};
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int maxn = 1e6;
double s[maxn], p[maxn];
const int mod=323232323;
set st;
struct node
{
int l,r,p,q;
int k;
}a[maxn];
void init(int n)
{
for(int yy=0;yy<=n;yy++)
{
a[yy].l=-1;
a[yy].r=-1;
a[yy].p=-1;
a[yy].q=-1;
a[yy].k=-1;
}
}
int main()
{
int m,Q,n;
while(~scanf("%d%d%d",&n,&m,&Q))
{
int kk=0;
init(m);
while(Q--)
{
getchar();
char op;
scanf("%c",&op);
if(op=='I'){
int ll,rr,yy,pp,qq;
scanf("%d%d%d%d%d",&ll,&rr,&yy,&pp,&qq);
a[yy].l=ll;
a[yy].r=rr;
a[yy].p=pp;
a[yy].q=qq;
a[yy].k=++kk;
}
if(op=='Q'){
int xx,ll,rr;
scanf("%d%d%d",&xx,&ll,&rr);
long long ans=0;
for(int i=ll;i<=rr;i++)
{
//printf("@=******%d %d %d %lld
",i,a[i].p,a[i].q,ans);
if(a[i].l==-1){
continue;
}
if(a[i].l<=xx&&a[i].r>=xx){
ans=((LL)a[i].p)*ans+a[i].q;
//printf("%d %d %d %lld
",i,a[i].p,a[i].q,ans);
ans=ans%mod;
}
}
printf("%lld
",ans);
}
if(op=='D'){
int yy;
scanf("%d",&yy);
for(int i=1;i<=m;i++)
{
if(a[i].k==yy){
a[i].l=-1;
a[i].k=-1;
}
}
}
}
}
}