Matrices with XOR property

应该先去看看这题的,补题的时候发现这题其实挺简单的。。

题意:n*m的格子用1-n*m的数去填,要求如果一个格子(i1,j1)与另外一个格子(i2,j2)满足(i1^j1)>(i2^j2),则a[i1][j1]>a[i2][j2]。问有多少种方法。

思路:n和m都在1000以内,我们可以预处理所有的格子的异或值。我们发现只有异或值大小不同的格子上的数有大小要求,而如果异或值相同的格子他们的大小关系是任意的,所以我们把所有异或值相同的数目求出来然后乘以其阶乘即可。

//#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<functional>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pI64d(x) printf("%I64d\n",x)
const int INF=1e9;
const int MOD=1e9+7;
const double eps=1e-7;
const int N=1e3+5;
int n,m,num[N][N],cnt[N*3];
void init()
{
memset(cnt,0,sizeof(cnt));
for(int i=1; i<N; i++)
for(int j=1; j<N; j++)
num[i][j]=i^j;
}
int main()
{
int t;
scanf("%d",&t);
init();
while(t--)
{
scanf("%d%d",&n,&m);
memset(cnt,0,sizeof(cnt));
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++) cnt[num[i][j]]++;
ll ans=1;
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
{
ans=ans*cnt[num[i][j]]%MOD;
cnt[num[i][j]]--;
}
printf("%I64d\n",ans);
}
return 0;
}


SPOJ-Matrices with XOR property,暴力打表!的更多相关文章

  1. ACM/ICPC 之 暴力打表(求解欧拉回路)-编码(POJ1780)

    ///找到一个数字序列包含所有n位数(连续)一次且仅一次 ///暴力打表 ///Time:141Ms Memory:2260K #include<iostream> #include< ...

  2. XTU OJ 1210 Happy Number (暴力+打表)

    Problem Description Recently, Mr. Xie learn the concept of happy number. A happy number is a number ...

  3. 【ZOJ】3785 What day is that day? ——浅谈KMP在ACM竞赛中的暴力打表找规律中的应用

    转载请声明出处:http://www.cnblogs.com/kevince/p/3887827.html    ——By Kevince 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这 ...

  4. HDU 1012 u Calculate e【暴力打表,水】

    u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  5. Codeforces 914 C 数位DP+暴力打表+思维

    题意 给出一个二进制数\(n\),每次操作可以将一个整数\(x\)简化为\(x\)的二进制表示中\(1\)的个数,如果一个数简化为\(1\)所需的最小次数为\(k\),将这个数叫做特殊的数, 问从\( ...

  6. Friends number NBUT - 1223 (暴力打表)

    Paula and Tai are couple. There are many stories between them. The day Paula left by airplane, Tai s ...

  7. HDU 1216 Assistance Required(暴力打表)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1216 Assistance Required Time Limit: 2000/1000 MS (Ja ...

  8. 暴力打表之hdu 2089

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2089 有两种方法: 1.数位DP算法 2.暴力打表——真是个好法子!!! 接下来是注意点: 1.一般这 ...

  9. HDU 5179 beautiful number (数位dp / 暴力打表 / dfs)

    beautiful number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

随机推荐

  1. 高性能Javascript总结

    一.加载和运行 Javascript代码执行会阻塞其他浏览器处理过程.充分利用webpack或gulp工具对文件打包压缩,减少js文件的数量,从而减少http请求的次数,以提高网页应用的实际性能. 二 ...

  2. GetClassName 取得的类名有

    今天上午稍微跟踪了一下自己的项目里面的各个空间,得知GetClassName可以取到以下类名:Static\Edit\Button\ComboBox\msctls_trackbar32\SysTabC ...

  3. 解决 FusionCharts3.2.1 首页无法载入的问题

    在实际项目中测试FusionCharts3.2.1时,发现首次载入无法正常载入,第二次载入就恢复正常!   原因:FusionCharts ID与变量名重复   以下是正常写法: var member ...

  4. MyBatis插入数据之后返回插入记录的id

    MyBatis插入数据的时候,返回该记录的id<insert id="insert" keyProperty="id" useGeneratedKeys= ...

  5. Tunneling cannot be enabled without the local_ip bound to an interface on the host. Please configure local_ip 192.168.30.71 on the host interface to be used for tunneling and restart the agen

    按照官方文档配置linux bridge 会出现一下问题 Tunneling cannot be enabled without the local_ip bound to an interface ...

  6. 设置windows status bar隐藏

    info.plist View controller-based status bar appearance 为 NO CGContextSaveGState: invalid context 0x0 ...

  7. Scala 的list

    9.1 使用列表 列表类型:跟数组一样,列表也是同质化的(homogeneous).即所有元素都要是同种类型. 列表结构:所有列表由两部分组成:Nil 和 ::(cons). 基本操作:主要有三个:h ...

  8. WPF中引入外部资源

    有时候需要在WPF中引入外部资源,比如图片.音频.视频等,所以这个常见的技能还是需要GET到. 第一步:在VS中创建一个WPF窗口程序 第二步:从外部引入资源,这里以引入图片资源为例 1)新建Reso ...

  9. canvas 在视频中的用法

    <!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...

  10. Hibernate查询语句HQL8大特点

    Hibernate拥有一种功能非常强大的查询语言,这种语言被有意得与SQL非常相似,便于开发人员掌握.但不要被HQL的语法表面所迷惑,HQL完全是面向对象的,可以用来过程多态.继承.关联等关系. 1. ...