2020 10 08 模擬賽 題解

2022-09-10 15:18:27 字數 3559 閱讀 2072

期望100-實際100

老師說是結論題。

其實可以直接打表,t[i]表示0-63中有t[i]對數與起來等於i,然後乘法原理即可。

(沒什麼難度。

#include #include using namespace std;

const int maxn = 100005;

const int mod = 1e9 + 7;

char s[maxn];

int a[maxn], t[64];

int main()

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

// printf("%d ", a[i]);

t[0] = 729; t[1] = 243; t[2] = 243; t[3] = 81; t[4] = 243; t[5] = 81; t[6] = 81; t[7] = 27; t[8] = 243; t[9] = 81; t[10] = 81; t[11] = 27; t[12] = 81; t[13] = 27; t[14] = 27; t[15] = 9; t[16] = 243; t[17] = 81; t[18] = 81; t[19] = 27; t[20] = 81; t[21] = 27; t[22] = 27; t[23] = 9; t[24] = 81; t[25] = 27; t[26] = 27; t[27] = 9; t[28] = 27; t[29] = 9; t[30] = 9; t[31] = 3; t[32] = 243; t[33] = 81; t[34] = 81; t[35] = 27; t[36] = 81; t[37] = 27; t[38] = 27; t[39] = 9; t[40] = 81; t[41] = 27; t[42] = 27; t[43] = 9; t[44] = 27; t[45] = 9; t[46] = 9; t[47] = 3; t[48] = 81; t[49] = 27; t[50] = 27; t[51] = 9;t[52] = 27; t[53] = 9; t[54] = 9; t[55] = 3; t[56] = 27; t[57] = 9; t[58] = 9; t[59] = 3; t[60] = 9; t[61] = 3; t[62] = 3; t[63] = 1;

long long ans = 1;

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

printf("%lld\n", ans % mod);

return 0;

}

打表**:

#include int t[64];

int main()

for(int i = 0; i <= 63; i++)

printf("t[%d] = %d;\n", i, t[i]);

return 0;

}

期望100-實際9

老師說是最短路。

可以在這裡執行最優解剪枝。

#include #include #include #include using namespace std;

const int maxn = 105;

int dx[4] = ;

int dy[4] = ;

int map[maxn][maxn], n, t;

void read(int &a)

while (s >= '0' && s <= '9')

a *= k;

return;

}struct node

};int ans[3][maxn][maxn];

void bfs(int sx, int sy)

if (cx < 1 || cx > n)

continue;

if (cy < 1 || cy > n)

continue;

if (ans[val][cx][cy] <= dis) // 剪枝 2(同剪枝 1

continue;

ans[val][cx][cy] = dis;

q.push(node(cx, cy, val, dis));}}

return;

}int main()

期望100-實際77

一道完全揹包,我記得我們之前做過類似題目的。

所以做k-1次完全揹包即可。

#include typedef long long ll;

const int maxn = 55;

const int maxd = 15;

const int maxm = 1000005;

int v[maxn][maxd];

ll dp[maxm], add[maxm];

int max(int x, int y)

int main()

printf("%lld\n", t);

return 0;

}

期望0-實際30????

當我們求到字首和之後,就需要把所有的滿足條件的超級音符選出最大的k個超級音符來。

又很顯然,暴力排序跑是不可能的,因此,我們就需要換個方法。因為對於乙個確定的起點i而言,找到以i為起點,往後數[l,r]這個區間的子段的最大值,是可求的。因為我們已經計算出來了字首和,那麼,[l,r]這個範圍內的最大值減去i-1這個位置的字首和就是我當前這個段能取得的最大值。

那麼,對於我的答案而言,每次都選取這樣的最優值,最後得到的是不是就是最優解?因此,我們可以用乙個堆來儲存這樣的一些資料,儲存對於每乙個起點i而言,取出[i+l,i+r]這個範圍內的最大值存入我們的優先佇列。

當我們取走乙個當前的區域性最優解之後,又由於我這個區間範圍內的次優解還可能比其他地方的最優解優,因此,假設t就是我們得到最優解得位置,我們在取走它之後,還需要再放進從i開始,[i+l,i+t-1]的最優解以及[i+t+1,i+r]的最優解,當然,如果t=l或者t=r時,需要特判。(思路來自lhy

#include using namespace std;

const int maxn = 500005;

long long a[maxn], sum[maxn];

long long n, m, l, r;

struct rmq st[maxn][25];

struct data

};priority_queueq;

void rmq() else

return;

}int work_v(int l, int r)

int work_index(int l, int r)

int main()

rmq();

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

while (m-- && !q.empty())

cnt2 = cnt;

cnt2.l = cnt.l_ + 1;

cnt2.r = cnt.r;

if (cnt2.l <= cnt2.r)

}printf("%lld", ans);

return 0;

}

模擬賽 circle 題解

題意 有n個數,問有多少個x,x leq t 滿足這n個數分別 x後,異或和為s。每個數小於 2 m 數字dp。由於是加法,需要記錄進製,因此從低位到高位dp。只要記錄下有幾個進製,就可以根據這n的數的大小知道究竟是哪幾個進製了。設 dp i,j,0 1 表示考慮到第i位,有j個進製,與t的大小關係...

模擬賽2 題解

這次模擬賽最後一道是提答題,就不寫題解了。orz這題 emmm,我無話可說。小範圍記憶化,大範圍遞迴求解 複雜度 o k sqrt 記 f i,j 表示前 j 個數中不被 a i,a dots,a n 整除的個數,答案即為 f 1,n 狀態轉移方程為 f i,j f i 1,j f i 1,j a ...

2021 02 10 模擬賽題解

比較水,就不說了。就是暴力優化,不知道複雜度為哈對,也過不了,就不放了。考慮暴力,即每次每個點向可以一波傳染的點連邊,然後縮點,求無入度的點數即可。考慮優化,你發現對於兩個點可以在點分樹上乙個點考慮先走到該點再到另乙個點,所以我們可以直接澱粉質,然後雙指標拆點連邊即可。include using n...