l洛谷 NOIP提高組模擬賽 Day2

2022-05-12 10:31:53 字數 1683 閱讀 4592

傳送門

## t1

區間修改+單點查詢。差分樹狀陣列。

#include#include

#include

using

namespace

std;

const

int maxn = 10000005

;inline

intrd()

while(isdigit(ch))

return f?x:-x;

}void

out(int

x)int

f[maxn],n,m,ans;

void update(int x,int

k)int query(int

x)int

main()

else

}return0;

}

view code

## t2

比賽的時候算錯複雜度,以為是個模擬。拿了$60pts$的暴力分。正解要用雙向鍊錶,不太想寫,留坑。

## t3

狀壓$dp$,考試的時候題意中有句話不理解,寫了三份**,結果發現都過不了大樣例 ($wtf??$),最後快結束時瞎交了乙份,結果拿了90。。最後發現中間有個地方沒開$long long$ ,虧死。設$dp[s][i]$表示現在選的集合為$s$,最後乙個選的為$i$的最大收益,然後再列舉乙個集合外的元素$j$,進行轉移。時間複雜度$o(2^n*n)$

#include#include

#include

#include

#include

#define int long long

using

namespace

std;

const

int maxn = 20

;typedef

long

long

ll;inline

intrd()

while(isdigit(ch))

return f?x:-x;

}int

n,m,k,t[maxn];

intval[maxn],ex[maxn][maxn];

ll dp[

1<

inline

void

max()

void dfs(int x,int

now)

if(x==n+1) return

; t[now+1]=x;dfs(x+1,now+1

); t[now+1]=0;dfs(x+1

,now);

}signed main()dp[

0][0]=0

;

for(register int i=1;i<=n;i++) dp[1

<

for(register int s=0;s<1

for(register int i=1;i<=n;i++)if((s&(1

<

))))

for(register int j=1;j<=n;j++)if(!(s&(1

<

))))

dp[s|(1

<

<

//cout

); cout

return0;

}

view code

洛谷 NOIP提高組模擬賽 Day1

傳送門 t1 一道結論題,設原來a隊能力最大的是x,那麼a隊的選擇方案就是 2 b隊的選擇方案就是 2 1 種,因為不能不選。其中 1 leq x leq n 那麼根據乘法原理,最後的答案就是 sum limits 2 2 1 化簡可得 ans n 2 2 1 然後乙個快速冪就行了。include ...

NOIP提高組模擬賽3

周圍大佬都說初中打過n遍,我乙個菜雞瑟瑟發抖。把斐波那契數列寫出來找了半天性質,用了半個多小時推出來 x兔子的父親,就是x減去是在斐波那契數列中最大的小於x的數 舉個栗子 13號兔子,應減去8,得到他的祖先5 10號兔子,應減去8,得到他的祖先2 預處理出斐波那契數列,然後讓ab中較大的到他的祖先,...

NOIP提高組模擬賽4

丹青千秋釀,一醉解愁腸 無悔少年枉,只願壯志狂 矩陣字首和加暴力 o n 2m 2 60pts有手就行 觀察資料範圍,猜測應該是求一種 o n 3 的演算法,想到之前做的題,應該是 n 2 枚舉行,n 處理乙個序列的答案,然後,就沒有然後了 對於乙個序列,求子段和為k的倍數,如何 o n 求解,考慮...