原创 1113 Integer Set Partition (25 point(s))

Given a set of N (>1) positive integers, you are supposed to partition them into two disjoint sets A​1​​ and A​2​​ of n

原创 關於因子分解的一類題型

1: 質因子分解   思路:由於質因子分解是唯一的(算術基本定理),因此只需要枚舉質因子(提前打表質數),計數即可。 AC code: #include<bits/stdc++.h> using namespace std; cons

原创 1034 Head of a Gang (30point(s))

One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A a

原创 三元組最小距離

題目:     已知三個升序整數數組a[l], b[m]和c[n]。請在三個數組中各找一個元素,是的組成的三元組距離最小。三元組的距離定義是:假設a[i]、b[j]和c[k]是一個三元組,那麼距離爲: Distance = max(|a[

原创 L2-023 圖着色問題 (25 point(s))

圖着色問題是一個著名的NP完全問題。給定無向圖G=(V,E),問可否用K種顏色爲V中的每一個頂點分配一種顏色,使得不會有兩個相鄰頂點具有同一種顏色? 但本題並不是要你解決這個着色問題,而是對給定的一種顏色分配,請你判斷這是否是圖着色問題的

原创 靜態鏈表常見題型總結

靜態鏈表  首先,靜態鏈表的原理是Hash,即通過建立一個結構體數組,使用下標去訪問數組元素; 一般化步驟:1)定義靜態鏈表 struct Node{ int add;//節點地址 typedef data;//數據域