關於數論的一些知識點,慢慢積攢

2021-08-17 01:28:19 字數 1124 閱讀 5276

數論的東西太多了,決定把一些遇到的定理在這裡整理一下

l(x) 求的是 lcm(1,2,3.....x)

lcm 求最小公倍數

l(1) = 1

l(x+1) =

else

}4. ceil() 向上取整

///test ceil() 向上取整

cout << "test ceil() 向上取整!" << endl;

cout << "ceil 1.2 = " << ceil(1.2) << endl; ///2

cout << "ceil 1.8 = " << ceil(1.8) << endl; ///2

cout << "ceil -1.2 = " << ceil(-1.2) << endl; ///-1

cout << "ceil -1.8 = " << ceil(-1.8) << endl; ///-1

cout << "ceil 0.0 = " << ceil(0.0) << endl; ///0

cout << endl;

5. floor() 向下取整

///test floor() 向下取整

cout << "test floor() 向下取整!" << endl;

cout << "floor 1.2 = " << floor(1.2) << endl; ///1

cout << "floor 1.8 = " << floor(1.8) << endl; ///1

cout << "floor -1.2 = " << floor(-1.2) << endl; ///-2

cout << "floor -1.8 = " << floor(-1.8) << endl; ///-2

cout << "floor 0.0 = " << floor(0.0) << endl; ///0

cout << endl;

拓撲排序

如果in(入度陣列)中存在兩個以上的in[x] == 0,該拓撲排序的順序無法判斷

如果in判定完畢後,還存在in[x] != 0,該拓撲排序中存在衝突,即存在環

關於演算法的一些知識點

set 不能用來計數,只能用來判斷是否存在這個string。include setstr 新增數值 str.insert str new set 預設是從小到大排序 兩個int插入用法,按照第乙個數值排序。set s 訪問第乙個值 s.begin 如果是雙int int start,end star...

關於集合的一些知識點

集合 集合,它也是一種陣列,它稱為 動態陣列 特點 宣告集合的時候,不需要指定集合的大小,當空間不夠時,會自動變大 arraylist可以存在重複資料 它儲存的資料是有順序的 採用的佇列的結構進行儲存 先進先出,後進後出 建立語法 arraylistlist new arraylist 這是一種泛型...

一些知識點

字串拼接 1.a join b a為元素之間的分隔符,b為待分割的序列 可用於輸出時的資料處理,元素間有空格,末尾沒有 2 s s s str1,str2,str3 前半部分為字串,後半部分為索引。用於引入,s是物件 3.format str1,str2,str3 與f 括號裡為已有變數 關於for...