题目链接

题目大意

要你求有多少个满足题目条件的矩阵mod 1e9+7

\(a[1][1]=2018\;\;a[i][j]为a[i-1][j]和a[i][j-1]的因子\)

题目思路

dp也就图一乐,真正比赛还得看打表

一直在想dp,其实却是打表找规律

只能说看到答案固定的题目就应该要去想打表

然后发现规律

打表代码

#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#define fi first
#define se second
#define debug printf(" I am here\n");
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int maxn=1e3+5,inf=0x3f3f3f3f,mod=1e9+7;
const double eps=1e-10;
int n,m,a[maxn][maxn],cnt;
int num[]={0,1,2,1009,2018};
void dfs(int x,int y,int n,int m){
if(x>n||y>m) return ;
if(x==1&&y==1){
a[1][1]=2018;
if(x==n&&y==m){
cnt++;
}else if(y==m){
dfs(x+1,1,n,m);
}else{
dfs(x,y+1,n,m);
}
}else if(x==1){
for(int i=1;i<=4;i++){
if(a[x][y-1]%num[i]!=0) continue;
a[x][y]=num[i];
if(x==n&&y==m){
cnt++;
}else if(y==m){
dfs(x+1,1,n,m);
}else{
dfs(x,y+1,n,m);
}
}
}else if(y==1){
for(int i=1;i<=4;i++){
if(a[x-1][y]%num[i]!=0) continue;
a[x][y]=num[i];
if(x==n&&y==m){
cnt++;
}else if(y==m){
dfs(x+1,1,n,m);
}else{
dfs(x,y+1,n,m);
}
}
}else{
for(int i=1;i<=4;i++){
if(a[x-1][y]%num[i]!=0) continue;
if(a[x][y-1]%num[i]!=0) continue;
a[x][y]=num[i];
if(x==n&&y==m){
cnt++;
}else if(y==m){
dfs(x+1,1,n,m);
}else{
dfs(x,y+1,n,m);
}
}
}
}
signed main(){
for(int i=1;i<=10;i++){
for(int j=1;j<=10;j++){
cnt=0;
dfs(1,1,i,j);
printf("%d ",cnt);
}
cout<<endl;
}
return 0;
}

代码

#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#define fi first
#define se second
#define debug printf(" I am here\n");
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int maxn=2e3+5,inf=0x3f3f3f3f,mod=1e9+7;
const double eps=1e-10;
int n,m;
int dp[maxn][maxn];
signed main(){
dp[1][1]=1;
for(int i=1;i<=2000;i++){
for(int j=1;j<=2000;j++){
if(i==1&&j==1) continue;
dp[i][j]=(dp[i-1][j]+dp[i][j-1]+1)%mod;
}
}
while(scanf("%d%d",&n,&m)!=-1){
printf("%d\n",1ll*dp[n][m]*dp[n][m]%mod);
}
return 0;
}

2018-div-matrix 题解(打表)的更多相关文章

  1. 喵哈哈村的魔法考试 Round #1 (Div.2) 题解

    喵哈哈村的魔法考试 Round #1 (Div.2) 题解 特别感谢出题人,qscqesze. 也特别感谢测题人Xiper和CS_LYJ1997. 没有他们的付出,就不会有这场比赛. A 喵哈哈村的魔 ...

  2. Educational Codeforces Round 65 (Rated for Div. 2)题解

    Educational Codeforces Round 65 (Rated for Div. 2)题解 题目链接 A. Telephone Number 水题,代码如下: Code #include ...

  3. Codeforces Round #466 (Div. 2) 题解940A 940B 940C 940D 940E 940F

    Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权 ...

  4. Codeforces Round #182 (Div. 1)题解【ABCD】

    Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...

  5. 喵哈哈村的魔法考试 Round #2 (Div.2) 题解

    喵哈哈村的魔法考试 Round #2 (Div.2) 题解 A.喵哈哈村的战争 题解: 这道题就是for一遍,统计每个村子的战斗力的和,然后统计哪个村子的战斗力和大一点就好了. 唯一的坑点,就是这道题 ...

  6. Educational Codeforces Round 63 (Rated for Div. 2) 题解

    Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...

  7. Codeforces Round #608 (Div. 2) 题解

    目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...

  8. Educational Codeforces Round 64 (Rated for Div. 2)题解

    Educational Codeforces Round 64 (Rated for Div. 2)题解 题目链接 A. Inscribed Figures 水题,但是坑了很多人.需要注意以下就是正方 ...

  9. Codeforces Round #525 (Div. 2)题解

    Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # inclu ...

  10. Codeforces Round #528 (Div. 2)题解

    Codeforces Round #528 (Div. 2)题解 A. Right-Left Cipher 很明显这道题按题意逆序解码即可 Code: # include <bits/stdc+ ...

随机推荐

  1. Java安全之Commons Collections7分析

    Java安全之Commons Collections7分析 0x00 前言 本文讲解的该链是原生ysoserial中的最后一条CC链,但是实际上并不是的.在后来随着后面各位大佬们挖掘利用链,CC8,9 ...

  2. 常用数据结构-集合(set)

    集合(set)是python中最容易被忽视的.使用集合的主要好处在于速度快. 集合的一些特性: 集合元素不能重复 不支持索引访问集合中的元素 集合使用散列之后,可以在O(1)时间内访问元素 支持一些常 ...

  3. Python爬虫练习(requests模块)

    Python爬虫练习(requests模块) 关注公众号"轻松学编程"了解更多. 一.使用正则表达式解析页面和提取数据 1.爬取动态数据(js格式) 爬取http://fund.e ...

  4. python数据类型之tuple(元组)

    tuple元组 关注公众号"轻松学编程"了解更多. 1.概述 本质上是一种有序的集合,和列表非常的相似,列表使用[]表示,元组使用**()**表示. 特点:一旦初始化,就不能发生改 ...

  5. GXOI2018 滚粗记

    今天考了一次蜜汁省选,滚粗了.想了想,还是写点什么记录一下 8:10 折腾一番总算拿到题目和样例了,一打开dpf,立马感觉到了不对劲. 题目一股浓浓的劣质模拟题的画风,先不说题目质量,单是排版质量都被 ...

  6. SQL Plus的使用详解(登录和常用命令)

    1.SQL Plus简介 SQL Plus工具是随 Oracle数据库服务器或客户端的安装而自动进行安装的管理与开发工具, Oracle数据库中所有的管理操作都可以通过 SQLPlus工具完成. SQ ...

  7. MSSQL 指定分隔符号 生成数据集

    DECLARE @xml VARCHAR(MAX)='磨毛:1 缩率:2 干磨:3 湿摩:4 水洗牢度:5 手感:6 防水:7 PH:8 日晒:9' SET @xml= '<root>'+ ...

  8. 在Linux下的安装mysql-5.7.28 心得总结

    mysql-5.7.28 在Linux下的安装教程图解 这篇文章主要介绍了mysql-5.7.28 的Linux安装,本文通过图文并茂的形式给大家介绍的非常详细,具有一定的参考借鉴价值,希望给有需要的 ...

  9. UNP——第三章,套接字编程介绍

    1.套接字结构 多数套接字函数都有套接字结构参数,每个协议族都定义了自己的套接字结构,以 sockaddr_ 开始,并对应协议族的唯一后缀. struct sockaddr_in { uint8_t ...

  10. parted分区对齐

    分区提示未对齐 [root@lab8106 ceph]# parted /dev/sdd GNU Parted 3.1 Using /dev/sdd Welcome to GNU Parted! Ty ...