zjuturtle 最近的时间轴更新
zjuturtle

zjuturtle

V2EX 第 245065 号会员,加入于 2017-07-28 09:39:23 +08:00
zjuturtle 最近回复了
109 天前
回复了 shaoshuang 创建的主题 宽带症候群 杭州电信 2000M 宽带办理踩坑记录
我也是余杭,一波投诉 299/月给了 1000/100.没有上行叠加包。实测大约 1100 上行/140 下行
2018-09-24 16:06:47 +08:00
回复了 chenchangjv 创建的主题 MacBook Pro 求推荐一款 mbp 外接显示器,现在准备是 p2415q
去亚马逊海淘个 LG UltraFine 4K 翻新版本吧
2018-04-13 22:03:31 +08:00
回复了 letianqiu 创建的主题 程序员 一道 FFT 相关的题
可以参考一下我的博客
https://zjuturtle.com/2017/12/26/fft/
2018-02-22 18:55:52 +08:00
回复了 harry890829 创建的主题 Apple 20 号在苹果官网定制了 macbook pro
其实你在苹果官网上买贵了 15%是有的,去麦克先生不好么
2018-02-20 23:05:09 +08:00
回复了 Weny 创建的主题 Apple 人生苦短, 不要 2k 屏幕,直接上 LG 5k 或者 iMac 27 5k
我有点后悔没买俩 5K
2018-02-19 17:17:07 +08:00
回复了 greenhat233 创建的主题 问与答 一道简单的 c++编程题求解答
@zjuturtle 日原题有很多变种我特么又贴错了,给跪。
原题
https://leetcode.com/problems/single-number/description/
解答
#include<iostream>
#include<vector>

using namespace std;
class Solution {
public:
int singleNumber(vector<int>& nums) {
int res = 0;
for (auto it = nums.begin(); it != nums.end(); it++) {
res ^= *it;
}
return res;
}
};
2018-02-19 17:13:27 +08:00
回复了 greenhat233 创建的主题 问与答 一道简单的 c++编程题求解答
@zjuturtle 日贴错了,应该是这个

#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
int singleNumber(vector<int>& nums) {
vector<int> positiveCounts(32, 0);
vector<int> negtiveCounts(32, 0);
for (auto it = nums.begin(); it != nums.end(); it++) {
auto tmp = *it;
int index = 0;
if (tmp > 0) {
while (tmp!=0) {
positiveCounts[index] += (tmp % 2);
tmp /= 2;
index++;
}
}
else {
tmp = -tmp;
while (tmp != 0) {
negtiveCounts[index] += (tmp % 2);
tmp /= 2;
index++;
}
}
}
int pos = 0,neg=0,p=1,n=1;
for (int i = 0; i < 32; i++) {
auto pbit = positiveCounts[i] %= 3;
auto nbit = negtiveCounts[i] %= 3;
pos += (pbit*p);
neg += (nbit*n);
p *= 2;
n *= 2;
}
if(pos>0)
return pos;
return -neg;
}
};
2018-02-19 17:12:26 +08:00
回复了 greenhat233 创建的主题 问与答 一道简单的 c++编程题求解答
leetcode 上有这道题目
https://leetcode.com/problems/single-number-ii/description/
时间复杂度 O(n)
空间复杂度 O(1)

using namespace std;
class Solution {
public:
vector<int> singleNumber(vector<int>& nums) {
int tmp=0,tmp1=1,numA=0,numB=0;
for (auto it = nums.begin(); it != nums.end(); it++) {
tmp ^= (*it);
}
while (tmp % 2 == 0) {
tmp1 *= 2;
tmp /= 2;
}

for (auto it = nums.begin(); it != nums.end(); it++) {
if ((tmp1 ^ (*it)) == ((*it)-tmp1)) {
numA ^= (*it);
}
else {
numB ^= (*it);
}
}
auto res = new vector<int>;
(*res).push_back(numA);
(*res).push_back(numB);
return *res;
}
};
2018-02-19 16:59:38 +08:00
回复了 AxtonYao 创建的主题 分享创造 新年换新个人页
现在的年轻人都这么屌了啊。。。
2018-02-18 12:46:35 +08:00
回复了 cgcs 创建的主题 问与答 有人买过 Coursera 的企业版吗?
Business 完全没意义啊。我现在个人自己学,基本上只要申请奖学金都能给通过。惟二比较麻烦的是审核需要 15 天,专项课程的每一个小课程都要单独申请
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1181 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 18:22 · PVG 02:22 · LAX 11:22 · JFK 14:22
Developed with CodeLauncher
♥ Do have faith in what you're doing.