当前位置:网站首页>CCF 2013 12-4 interesting numbers
CCF 2013 12-4 interesting numbers
2022-06-11 06:07:00 【Tcoder-l3est】
CCF 2013 12-4 Interesting numbers
9/5/2021 5:03:56 PM
subject
Problem description
We call a number interesting , If and only if :
1. Its numbers only contain 0, 1, 2, 3, And all four numbers have appeared at least once .
2. be-all 0 All over the world 1 Before , And all 2 All over the world 3 Before .
3. The highest number is not 0.
therefore , The smallest interesting number that fits our definition is 2013. in addition to ,4 There are two more interesting numbers :2031 and 2301.
Please calculate that there happens to be n The number of interesting numbers of bits . Because the answer can be very big , Just output the answer divided by 1000000007 The remainder of .
Input format
There is only one line of input , Including exactly one positive integer n (4 ≤ n ≤ 1000).
Output format
There is only one line of output , Including just n The number of interesting integers divided by 1000000007 The remainder of .
The sample input
4
Sample output
3
Answer key :
Key Word : digit DP、 Status determination
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int MOD = 1000000007;
LL dp[1010][8]; //dp[i][j] It means the first one i Bit compliance status j The number of legal numbers
/* 0 It only includes 2 1 It only includes 2、0 2 It only includes 2、3 3 It only includes 2、0、1 4 It only includes 2、0、3 5 contain 4 Kind of number */
int main()
{
int n; cin>>n;
for(int i=1;i<=n;i++){
dp[i][0] = 1;// The first must be 2 Or say Add 2 Must be satisfied with
// It only includes 2 0 It can be 2 Then add 0 But 2 0 Add casually 2 perhaps 0
dp[i][1] = (dp[i-1][0] + dp[i-1][1]*2 ) % MOD;
// It only includes 2、3 2 +3 perhaps 23 + 3
dp[i][2] = (dp[i-1][0] + dp[i-1][2] ) % MOD;
// It only includes 2、0、1: 2 0 +1 2 0 1 + 1 2
dp[i][3] = (dp[i-1][1] + dp[i-1][3]*2) % MOD;
dp[i][4] = (dp[i-1][1] + dp[i-1][2] + dp[i-1][4]*2) % MOD;
dp[i][5] = (dp[i-1][3] + dp[i-1][4] + dp[i-1][5]*2) % MOD;
}
cout<<dp[n][5];
return 0;
}
understand :
DP First you have to see : Then this can actually enumerate states Then write the state transition equation
The final result is OK
And a little bit more
Multiple states Not all meet the requirements As long as we can transfer the qualified Then take that number !
DP[i][j] The first i position The first j States !
边栏推荐
- Which company is better in JIRA organizational structure management?
- All the benefits of ci/cd, but greener
- Experimental report on information management and information system [information security and confidentiality] of Huazhong Agricultural University
- Chapter 1 of machine learning [series] linear regression model
- All questions and answers of database SQL practice niuke.com
- FPGA设计中提高工作频率及降低功耗题目合集
- Yonghong Bi product experience (I) data source module
- 跨境电商测评自养号团队应该怎么做?
- Login and registration based on servlet, JSP and MySQL
- 使用Batch管理VHD
猜你喜欢

Login and registration based on servlet, JSP and MySQL

Warmly celebrate that yeyanxiu, senior consultant of Longzhi, won the title of "atlassian Certified Expert"

Can Amazon, express, lazada and shrimp skin platforms use the 911+vm environment to carry out production number, maintenance number, supplement order and other operations?

FPGA interview notes (IV) -- sequence detector, gray code in cross clock domain, ping-pong operation, static and dynamic loss reduction, fixed-point lossless error, recovery time and removal time

FPGA面試題目筆記(四)—— 序列檢測器、跨時鐘域中的格雷碼、乒乓操作、降低靜動態損耗、定點化無損誤差、恢複時間和移除時間

How to use the markdown editor

SQLI_ LIBS range construction and 1-10get injection practice

The artistic director and production designer of Disney's Mandalorian revealed the virtual scene production behind it

Free get | full function version of version control software

亚马逊、速卖通、Lazada、虾皮平台在用911+VM的环境可以进行产号、养号、补单等操作吗?
随机推荐
Continuous update of ansible learning
call和apply和bind的区别
Can Amazon, express, lazada and shrimp skin platforms use the 911+vm environment to carry out production number, maintenance number, supplement order and other operations?
Free get | full function version of version control software
使用Meshlab对CAD模型采样点云,并在PCL中显示
Control your phone with genymotion scratch
Servlet
Chapter 1 of machine learning [series] linear regression model
Super (subclass)__ init__ And parent class__ init__ ()
FPGA面试题目笔记(三)——跨时钟域中握手信号同步的实现、任意分频、进制转换、RAM存储器等、原码反码和补码
配置Rust编译环境
Elk log system practice (V): install vector and output data to es and Clickhouse cases
Data quality: the core of data governance
Using Internet of things technology to accelerate digital transformation
Box model
Completabilefuture asynchronous task choreography usage and explanation
Notes sur les questions d'entrevue de la FPGA (IV) - - détecteur de séquence, Code gris dans le domaine de l'horloge croisée, opération de ping - pong, réduction de la perte statique et dynamique, err
[usual practice] explore the insertion position
FIFO最小深度计算的题目合集
Managing VHDS using batch