原创 找第k小的數

#include<bits/stdc++.h> using namespace std; int a[100]; int select(int left,int right,int k) { if(left>=right)ret

原创 求數組中第k小的元素

方法一:分治:   #include<iostream> using namespace std; int a[100]; int f(int left,int right) { if(left==right) {

原创 s中子串”abc”的個數

鏈接:https://ac.nowcoder.com/acm/contest/1083/A 來源:牛客網   題目描述 給出一個字符串s,你需要做的是統計s中子串”abc”的個數。子串的定義就是存在任意下標a<b<c,那麼”s[a]s[b

原创 循環賽日程表

#include<bits/stdc++.h> using namespace std; int a[1000][1000]; void f(int k) { a[1][1]=1; a[1][2]=2; a[

原创 並查集 牛客1080/B

鏈接:https://ac.nowcoder.com/acm/contest/1080/B 來源:牛客網   題目描述 tokitsukaze有n個數,需要按順序把他們插入哈希表中,哈希表的位置爲0到n-1。 插入的規則是: 剛開始哈希表

原创 四維dp

鏈接:https://ac.nowcoder.com/acm/contest/1072/A 來源:牛客網   題目描述 設有N*N的方格圖(N ≤ 10,我們將其中的某些方格中填入正整數,而其他的方格中則放入數字0。如下圖所示(見樣例):

原创 全排列問題

#include<bits/stdc++.h> using namespace std; int b[100]; int vis[3000]; int n;//求1到n的全排列 void dfs(int t) { if(t>n)

原创 整數劃分問題

#include<bits/stdc++.h> using namespace std; int sum(int n,int m)//把正整數n劃分成最大項爲m的方法數。 { if(n==1||m==1)return 1;

原创 C - 4-adjacent(思維題)

題目鏈接:https://atcoder.jp/contests/arc080/tasks/arc080_a 題意: 給你n個數,問你能不能找到一種排列使相鄰兩個數的乘積爲4的倍數。是輸出“Yes”否則輸出“No”; 思路: 兩個數的乘積

原创 D - Grid Coloring(思維)

題目鏈接:https://atcoder.jp/contests/arc080/tasks/arc080_b Problem Statement We have a grid with HH rows and WW columns of

原创 D - Decrease (Contestant ver.)(思維好題)

Problem Statement We have a sequence of length N consisting of non-negative integers. Consider performing the following

原创 C - Cat Snuke and a Voyage(dfs)

題目鏈接:https://atcoder.jp/contests/arc079/tasks/arc079_a 題意: 給你n個點m條邊; 問你是否存在一條從1到n的長度爲2的邊; 代碼:   #include<iostream> #in

原创 D - 11(組合數學)

Problem Statement You are given an integer sequence of length n+1n+1, a1,a2,...,an+1a1,a2,...,an+1, which consists of t

原创 C - Splitting Pile(前綴和)

題意: 給你長度爲n的數組。A選前面連續的幾個,剩餘全部的給B。(每個人有1個數) 求:A怎麼選才能選才能使A中所有數的和與B中所有數的和差值最小,輸出該差值的絕對值。 代碼:   #include<bits/stdc++.h> #de

原创 D - Built?(最小生成樹)

題目鏈接:https://atcoder.jp/contests/arc076/tasks/arc076_b Problem Statement There are NN towns on a plane. The ii-th town