csp模擬 模擬測試16

2022-02-03 07:34:30 字數 3489 閱讀 7719

fdasds

#include using namespace std;

#define cle(a) memset(a, 0, sizeof(a))

inline int read()

const int mod = 1e9 + 7, maxn = 1e3 + 100;

int n, m, ans = 0;

int f[maxn][maxn];

int jl[maxn][maxn], a[maxn][maxn];

int jlh1b[6], jll1b[6];

int jlh2b[6], jll2b[6];

int jlh1e[6], jll1e[6];

int jlh2e[6], jll2e[6];

int vis[6][6];

void dfs1(int x, int y, int col)

}void dfs(int cur, int cnt)

}int now = 0;

for (int i = 1; i <= n; i++)

}int col = jl[1][1];

int line = 1, row = 1;

for (int i = 1; i <= m; i++)

for (int i = 1; i <= n; i++)

ans ++;

ans %= mod;

return;

}int row = cur % m, line = cur / m + 1;

if (row == 0) row = m;

if (cur % m == 0) line--;

if (a[line][row] == 1) dfs(cur + 1, cnt);

else if (a[line][row] == 2) dfs(cur + 1, cnt + 1);

else

}signed main()

}if (m < 5 && n < 5) return dfs(1, 0), cout << ans << endl, 0;

for (int i = 1; i <= n; i++) f[i][1] = i * 2;

for (int i = 1; i <= m; i++) f[1][i] = i * 2;

for (int i = 2; i <= n; i++)

for (int j = 2; j <= m; j++)

f[i][j] = (f[i - 1][j] + f[i][j - 1] + (i + j - 1) * 2) % mod;

cout << f[n][m] % mod << endl;

}

#include using namespace std;

#define cle(a) memset(a, 0, sizeof(a))

inline int read()

const int mod = 1e9 + 7, maxn = 1e3 + 100;

int n, m, ans = 0;

int f[maxn][maxn];

int jl[maxn][maxn], a[maxn][maxn];

int jlh1b[6], jll1b[6];

int jlh2b[6], jll2b[6];

int jlh1e[6], jll1e[6];

int jlh2e[6], jll2e[6];

int vis[6][6];

void dfs1(int x, int y, int col)

}void dfs(int cur, int cnt)

}int now = 0;

for (int i = 1; i <= n; i++)

}int col = jl[1][1];

int line = 1, row = 1;

for (int i = 1; i <= m; i++)

for (int i = 1; i <= n; i++)

ans ++;

ans %= mod;

return;

}int row = cur % m, line = cur / m + 1;

if (row == 0) row = m;

if (cur % m == 0) line--;

if (a[line][row] == 1) dfs(cur + 1, cnt);

else if (a[line][row] == 2) dfs(cur + 1, cnt + 1);

else

}signed main()

}if (m < 5 && n < 5) return dfs(1, 0), cout << ans << endl, 0;

for (int i = 1; i <= n; i++) f[i][1] = i * 2;

for (int i = 1; i <= m; i++) f[1][i] = i * 2;

for (int i = 2; i <= n; i++)

for (int j = 2; j <= m; j++)

f[i][j] = (f[i - 1][j] + f[i][j - 1] + (i + j - 1) * 2) % mod;

cout << f[n][m] % mod << endl;

}

dp,第一位表示左面的長度,第二位表示左面的左括號數目,具體解析見**

#include #define int long long

using namespace std;

inline int read()

const int mod = 1e9 + 7, maxn = 1e6 + 1000;

int jc[maxn], ny[maxn], jcny[maxn];

inline int qpow(int x, int y)

int c(int n, int m)

signed main()

int ans = 0;

for (int i = 0; i <= n - m; i++)

}cout << ans % mod << endl;

}

正解dp,轉移很複雜,這裡只給出暴力**,要打好概率dp的暴力!!!

#include using namespace std;

#define int long long

inline int read()

int x, n; double p, ans;

void dfs(int cnt, double now, double cur)

dfs(cnt + 1, now * 2, cur * p);

dfs(cnt + 1, now + 1, cur * (1 - p));

}signed main()

csp模擬 模擬測試4

t1是暴力分,t2當時沒有花太多時間去推導,一見到t2就十分害怕,便放過了它,t3的話花了大量的時間推了乙個錯誤的解,以後對於t2這種題不要未戰先怯,一點一點的去推導!那一天我們在教室裡許下約定。我至今還記得我們許下約定時的歡聲笑語。我記得她說過她喜歡吃餅乾,很在意自己體重的同時又控制不住自己。她跟...

CSP模擬 模擬測試5

題意是讓求平均值第k小的連續子區間。發現直接計算無論怎麼優化都是 n 2 的,然後發現這樣找k個的似乎可以考慮二分答案。簡單推一下式子。記 sum i 為字首和,顯然符合條件的區間有 frac leq mid 即 sum j j times mid leq sum i i times mid 預設 ...

CSP2019模擬測試 遊戲

給定乙個n m n mn m的矩形方格紙,每次可以把它裁為兩個子矩形,若裁出乙個1 1 1 11 1則勝,判斷先手是否必勝。n 2000,m 2000 n le 2000,m le 2000 n 2000 m 2 000 直觀的想法是設f i j f i j f i j 為i ji j i j的矩形...