IT討論區(116) 加拿大救生艇門已開

狼王托迪10

1001 回覆
0 Like 1 Dislike
海獅牌床褥 2021-04-20 10:24:10
實驗羊 2021-04-20 10:25:53
硬心傳件師-菊花 2021-04-20 10:28:00
freecodecamp 條條片都567粒鐘,點睇呀
無糖人生 2021-04-20 10:54:45
肥仔條條fing 2021-04-20 11:01:09
Mike_Chan 2021-04-20 11:05:12
狼王托迪10 2021-04-20 11:10:49
腦若傷殘 2021-04-20 11:26:22
無糖人生 2021-04-20 11:26:37
Trinidad 2021-04-20 11:28:45
lang嚟講有呢啲operator都算係基本要求
咖喱牛 2021-04-20 11:31:47
心繫社會 2021-04-20 11:32:37
mask_11 應該點樣理解
Code4Food 2021-04-20 11:34:50
Actually this can be even more simplified if we implement a 2-bit counter using boolean logic ourselves:

std::vector<int64_t> input;

// The bits in a & b implement 64 parallel 2-bit counters to keep track 
// of number of bits in input at position i. a[i] is bit 0 and b[i] bit 1 of the
// counter for position i.
int64_t a = 0, b = 0;

// After this loop finishes, a hold the number that appears once and
// b the number that appears twice.
for (int64_t n_i : input) {
  b ^= a & n_i;
  a ^= n_i;
}


I think this is more efficient and elegant.
Code4Food 2021-04-20 11:42:12
我用4個bit黎儲一個2-bit number,加完1之後有機會overflow,咁and mask_11就會清除overflow bit,等結果係2個bit。其實用個兩個mask應該叫mask_0001同mask_0011會清楚啲。要防止overflow去隔離個counter其實三個bit都得但兩個bit mask唔會係1111 同 3333咁容易寫,人手有機會寫錯。
badisgood 2021-04-20 11:43:23
想問下
一般做trainee ot 冇補水 正常?
海獅牌床褥 2021-04-20 11:46:47
themida 2021-04-20 11:51:23
完全跟唔到大佬思路
腦若傷殘 2021-04-20 11:52:24
badisgood 2021-04-20 11:54:21

突然唔想轉行
宜家份工就係正係唔洗ot
就算ot 都有補水
手一黏便緊(UTC+9 2021-04-20 11:55:50
基本野...
你明唔明概念上要maintain bit counter先?
心繫社會 2021-04-20 12:13:12
所以等於modulo 4?
omg
Code4Food 2021-04-20 12:25:36
yes, mod 4 得 0, 1, 2 同 3 用兩個bit儲到。一個64-bit variable可以分成32個2-bit counter。但係咁樣做有一個問題係加數進位會overflow入隔離個counter,所以要3個bit先方便。每一次計完加數後mask off返個overflow bit就可以解決進位嘅問題。但3個bit又會令到人手寫bit mask constant教難,所以就用4個bit。

如果呢有睇過SIMD programming(MMX,SSE, AVX, AltiVec, VSX, Neon....) 其實概念上好類似,不過我同integer unit嘅ALU黎做parallel addition,要人手解決overflow嘅問題咁解。
手一黏便緊(UTC+9 2021-04-20 12:25:54
係 就係mod4
Trinidad 2021-04-20 14:19:19
IT9 OT冇補水係正常
正常計補水係啲weekend/平日半夜嘅official scheduled work就可能有得補
橫點橫 2021-04-20 14:31:28
Official scheduled work分分鐘都無
好撚鐘意office hour 9-6 但schedule 7 8點做個task然後話第二朝一定要
吹水台自選台熱 門最 新手機台時事台政事台World體育台娛樂台動漫台Apps台遊戲台影視台講故台健康台感情台家庭台潮流台美容台上班台財經台房屋台飲食台旅遊台學術台校園台汽車台音樂台創意台硬件台電器台攝影台玩具台寵物台軟件台活動台電訊台直播台站務台黑 洞