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. netty-socketio即时通讯

    jar包和依赖包在360云盘中:所有文件 > 学习 > jar包 > netty-socketio-1.7.10以及依赖 原文链接:http://www.cnblogs.com/al ...

  2. 关于如何用jq定位到某个元素的索引

    在点击事件触发时候,通常如果有同样的className的列表我们都需获取它的索引来知道到底点击的是那一个 $('.info_content').mousemove(function(){ var ro ...

  3. nGrinder技术架构图

  4. python打开文件可以有多种模式

    一.python打开文件可以有多种模式,读模式.写模式.追加模式,同时读写的模式等等,这里主要介绍同时进行读写的模式r+ python通过open方法打开文件 file_handler = open( ...

  5. 洛谷 P2419 [USACO08JAN]牛大赛Cow Contest

    题目背景 [Usaco2008 Jan] 题目描述 N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a p ...

  6. Stream.iterate方法与UnaryOperator

    前提:本人在翻看<Java核心技术II>的时候在p17的时候发现一段代码不是很明白.不知道为什么就输出了1,2,3,4,5,6,7,8,9,10,...也不知道n-n.add(BigInt ...

  7. 安卓统一推送联盟融云成唯一IM云服务企业

    10月16日,安卓统一推送联盟在北京正式成立,来自中国信息通信研究院,华为.小米.OPPO等手机厂商,BAT等互联网巨头公司等75家机构及企业代表参加了联盟成立大会,融云也受邀参会并成为首批成员单位中 ...

  8. KissXML类库的使用方法

    1.添加附件里面的KissXML到工程 2.加入libxml2.dylib 到Frameworks 3.修改工程信息,右击Targets下工程名选“Get Info”,进入修改Header Searc ...

  9. js设置元素float的问题

    用js设置一个元素的float样式 div.style.float = 'left'; 这句话在谷歌浏览器或许没问题,但是在IE,火狐下会无效 正确写法是 div.style.styleFloat = ...

  10. 解决IllegalBlockSizeException:last block incomplete in decryption异常

    解决IllegalBlockSizeException:last block incomplete in decryption异常分类: webkit android最近做个加解密的实现,虽然实现了, ...