排除所有不符合条件后根据当前位置上下界计算,

由于前面取的数肯定在之后的区间内,所以去掉已取的个数即可。

 #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
#define LL __int64
const int N=;
const LL mod=;
int t,n,num,b[N],c[N];
bool flag;
LL ans;
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=;i<n;i++) scanf("%d",&b[i]);
for(int i=;i<n;i++) scanf("%d",&c[i]);
if(b[]!=c[])
{
puts(""); continue;
}
flag=;
num=ans=;
for(int i=;i<n;i++)
{
if(b[i]!=b[i-]&&c[i]!=c[i-] || b[i-]<b[i] || c[i-]>c[i])//不符合条件
{
flag=; break;
}
else if(c[i]!=c[i-]||b[i]!=b[i-]) num++; //已确定的数字数+1
else
{
ans=(ans*(c[i]-b[i]+-num))%mod;//该位上未确定的数字中的符合条件的个数
num++;//已确定的数字数+1
}
}
if(flag)
{
puts(""); continue;
}
printf("%I64d\n",ans);
}
}
/*
2
5
4 4 1 1 1
4 5 5 5 5
*/

BestCoder 2nd Anniversary 1002 Arrange的更多相关文章

  1. hdu 5719 BestCoder 2nd Anniversary B Arrange 简单计数问题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5719 题意:一个数列为1~N的排列,给定mn[1...n]和mx[1...n],问有符合的排列数为多少 ...

  2. BestCoder 2nd Anniversary的前两题

    Oracle Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Su ...

  3. BestCoder 2nd Anniversary

    A题 Oracle http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=703&pid=1001 大数相加: ...

  4. BestCoder 1st Anniversary ($) 1002.Hidden String

    Hidden String Accepts: 437 Submissions: 2174 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 26 ...

  5. BestCoder 2nd Anniversary/HDU 5719 姿势

    Arrange Accepts: 221 Submissions: 1401 Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/2 ...

  6. hdu 5720 BestCoder 2nd Anniversary Wool 推理+一维区间的并

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5720 题意:有n(n <= 105)个数 ,每个数小于等于 1018:问在给定的[L,R]区间中 ...

  7. BestCoder 2nd Anniversary 1001 Oracle

    找到最小的非零数字拆开来相加. 高精度. #include <iostream> #include <cstdio> #include <cstring> #inc ...

  8. BestCoder 2nd Anniversary/HDU 5718 高精度 模拟

    Oracle Accepts: 599 Submissions: 2576 Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/26 ...

  9. 暴力+降复杂度 BestCoder Round #39 1002 Mutiple

    题目传送门 /* 设一个b[]来保存每一个a[]的质因数的id,从后往前每一次更新质因数的id, 若没有,默认加0,nlogn复杂度: 我用暴力竟然水过去了:) */ #include <cst ...

随机推荐

  1. 原来真的不会用指针[*p++]

    Describe: 有2字节字符数据,需要转换成2字节的短整型,字符数据低字节在前. Analyse: 其实就是取一下数据,移位再或一下就好了,大伙都这样想的. Ex1: 假设tmp1就是短整型,p指 ...

  2. sketchup 导出 fbx文件 单位 错误

    最近在使用sketchup导出fbx文件到unity中使用时,发生了尺度单位上的错误.按照网上给出的标准教程,选定模型的单位为十进制-米.导出时选项选择'米',但是得到的fbx文件在unity中出现了 ...

  3. I/O多路复用之epoll

    1.select.poll的些许缺点 先回忆下select和poll的接口 int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set ...

  4. No1_4.数组的基本操作_Java学习笔记

    import java.util.Arrays; public class HelloArrayOp { public static void main(String[] args) { // TOD ...

  5. ArtTemplate 使用笔记

    新一代 javascript 模板引擎:artTemplate-3.0 下载地址:https://github.com/aui/artTemplate 快速上手请参考:https://github.c ...

  6. [原]C语言实现的快速排序,采用分治策略,递归实现

    #include<stdio.h> #define LEN 8 int a[LEN] = { 5, 2, 4, 7, 1, 3, 2, 6 }; int Partition(int a[] ...

  7. RenderPartial RenderAction Partial Action

    MVC Razor中有不同的展现partial view的方法,许多开发人员子在选择使用 RenderPartial or RenderAction or Partial or Action help ...

  8. java通过jdbc连接mysql数据库

    下载mysql驱动包: http://dev.mysql.com/downloads/file.php?id=456317 解压之后里面有个mysql-connector-java-5.1.35-bi ...

  9. Asp.net web服务处理程序(第六篇)

    四.Web服务处理程序 对于Web服务来说,标准的方式是使用SOAP协议,在SOAP中,请求和回应的数据通过XML格式进行描述.在Asp.net 4.0下,对于Web服务来说,还可以选择支持Ajax访 ...

  10. mysql select不使用任何锁(select with nolock)

    在ms sql中可以通过with(nolock)选项指定查询不锁表,在mysql中没有这个选项,需要通过set语句来设置不锁表: SET TRANSACTION ISOLATION LEVEL REA ...