BestCoder 2nd Anniversary 1002 Arrange
排除所有不符合条件后根据当前位置上下界计算,
由于前面取的数肯定在之后的区间内,所以去掉已取的个数即可。
#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的更多相关文章
- hdu 5719 BestCoder 2nd Anniversary B Arrange 简单计数问题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5719 题意:一个数列为1~N的排列,给定mn[1...n]和mx[1...n],问有符合的排列数为多少 ...
- BestCoder 2nd Anniversary的前两题
Oracle Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Su ...
- BestCoder 2nd Anniversary
A题 Oracle http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=703&pid=1001 大数相加: ...
- BestCoder 1st Anniversary ($) 1002.Hidden String
Hidden String Accepts: 437 Submissions: 2174 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 26 ...
- BestCoder 2nd Anniversary/HDU 5719 姿势
Arrange Accepts: 221 Submissions: 1401 Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/2 ...
- hdu 5720 BestCoder 2nd Anniversary Wool 推理+一维区间的并
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5720 题意:有n(n <= 105)个数 ,每个数小于等于 1018:问在给定的[L,R]区间中 ...
- BestCoder 2nd Anniversary 1001 Oracle
找到最小的非零数字拆开来相加. 高精度. #include <iostream> #include <cstdio> #include <cstring> #inc ...
- BestCoder 2nd Anniversary/HDU 5718 高精度 模拟
Oracle Accepts: 599 Submissions: 2576 Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/26 ...
- 暴力+降复杂度 BestCoder Round #39 1002 Mutiple
题目传送门 /* 设一个b[]来保存每一个a[]的质因数的id,从后往前每一次更新质因数的id, 若没有,默认加0,nlogn复杂度: 我用暴力竟然水过去了:) */ #include <cst ...
随机推荐
- PL/SQL文档
http://www.oracle.com/technetwork/database/features/plsql/index.html 注册表学习 http://itlab.idcquan.com/ ...
- 自定义tableviewCell的分割线
第一种:addsubview UIView *line = [[UIView alloc]initWithFrame:CGRectMake(10, cellH-0.5, DEVW-10, 0.5)]; ...
- hdu1219
Problem Description Ignatius is doing his homework now. The teacher gives him some articles and asks ...
- (转) 谈C/C++指针精髓
原文:http://www.cnblogs.com/madengwei/archive/2008/02/18/1072410.html [摘要] 指针是C和C++语言编程中最重要的概念之一, ...
- POJ2533:Longest Ordered Subsequence(LIS)
Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence ...
- 【solr基础教程之一】Solr相关知识点串讲
Solr是Apache Lucene的一个子项目.Lucene为全文搜索功能提供了完备的API,但它只作为一个API库存在,而不能直接用于搜索.因此,Solr基于Lucene构建了一个完 ...
- 初学者必看:精心整理的Javascript操作JSON总结
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式.同时,JSON是 JavaScript 原生格式,这意 ...
- ubuntu 新建zend framework 项目
1. sudo apt-get install zend-framework /usr/share/php/libzend-framework-php 2. 配置include_path /etc/p ...
- 小希的迷宫(HDU 1272 并查集判断生成树)
小希的迷宫 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- 使用TypeScript实现简单的HTML5贪吃蛇游戏
TypeScript是一种由微软开发的自由和开源的编程语言.它是JavaScript的一个超集,而且本质上向这个语言添加了可选的静态类型和基于类的面向对象编程.安德斯·海尔斯伯格,C#的首席架构师,已 ...