牛客國慶集訓派對Day4

2021-08-28 17:25:32 字數 2876 閱讀 6946

a:把b=n;

#include#include#include#includeusing namespace std;

int main()

d:由於是個完全圖,選擇乙個權值最小的點,其他所有的點向它連線就行了。注意點為1的時候輸出0;

#include#include#include#includeusing namespace std;

typedef long long ll;

const int maxn = 1e5 + 10;

ll a[maxn];

int main()

printf("%lld\n", sum + ans * (n - 2));

return 0;

}

g:列舉區間長度,那麼對於區間長度為len時,a[i]位置就會被覆蓋len次(前端和後端的覆蓋預處理,達不到len次);

#include#includeusing namespace std;

typedef long long ll;

typedef pairpii;

const ll mod = 1e9 + 7;

const int maxn = 3e5 + 10;

ll a[maxn], w[maxn], b[maxn];

ll sum[maxn];

int main()

for(int i = 1; i <= n; ++i) scanf("%lld", &w[i]);

/*ll u = 0;

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

}printf("## %lld\n", u);

*/for(int i = n; i >= 1; --i)

ll res = 0, ans = 0;

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

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

return 0;

}

h:

結論:每層的黑點數都是偶數則後手勝,否則先手勝;

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

#define met(s) memset(s, 0, sizeof(s))

#define rep(i, a, b) for(int i = a; i <= b; ++i)

template inline void scan_d(t &ret) }

typedef long long ll;

typedef unsigned long long ull;

typedef pairpii;

const int inf = 0x3f3f3f3f;

const ll mod = 1e9 + 7;

const int maxn = 1e3 + 5;

vectorg[maxn];

int col[maxn], num[maxn];

void dfs(int x, int fa, int d)

}int main()

dfs(1, -1, 0);

bool flag = true;

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

} if(!flag) puts("first");

else puts("second");

return 0;

}

i:

帶根節點:(a[

i]+1

)∗(a

[i+1

]+1)

∗(a[

i+2]

+1).

..

(a[i] + 1)*(a[i + 1] + 1) * (a[i + 2] + 1)...

(a[i]+

1)∗(

a[i+

1]+1

)∗(a

[i+2

]+1)

...不帶根節點:k∗(

k+1)

/2

k * (k + 1) / 2

k∗(k+1

)/2.

#include#includeusing namespace std;

typedef long long ll;

typedef pairpii;

const ll mod = 998244353;

const int maxn = 1e7 + 10;

int main()

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

return 0;

}

j:

不說話的也有可能是復讀機;

#include#include#include#includeusing namespace std;

typedef long long ll;

const int maxn = 1e5 + 10;

char str[1010][210];

int a[2010], b[2010], vis[2010];

int vi[2010];

int main() else vis[a[i]] = 1;}}

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

sort(b, b + p); bool flag = false;

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

}puts("");

return 0;

}

2020牛客國慶集訓派對day4 補題

2020牛客國慶集訓派對day4 b 題意 題意 求最長等差序列的長度。dp 攤派了我講不明白,參考下這兩篇部落格吧 捂臉 傳送門1 傳送門2 include include include include include include include using namespace std ty...

牛客國慶集訓派對Day4 G I H

小 bo 有 n 個正整數 a1.an,以及乙個權值序列 w1 wn,現在他定義 現在他想知道 你只需要輸出答案對 109 7 取模後的值 第一行乙個正整數 n 第二行 n 個正整數 a1.an 第三行 n 個正整數 w1.wn 輸出答案對 109 7 取模後的值示例1 複製3 1 1 1 1 1 ...

牛客國慶集訓派對Day4 區間權值

對於這種式子 f l,r sum a i times w 一般情況下,我們先仿照答案寫出前幾項,看看有沒有規律 定義字首和 s k sum a i 把要求出的式子 sum sum f l,r 展開來寫 begin f 1,1 f 1,2 f 1,3 f 1,4 dots f 1,n f 2,2 f ...