[note] 知乎course – 上班族的极简健康课

树立健康的正确观念~
健康三要素:饮食、运动、睡眠
饮食:
每天的饮食中,1/2是蔬菜;1/4谷物、粗粮、全麦等主食;1/4肉类等高蛋白质。除此之外,加一袋牛奶,一个水果~
果汁不能代替水果~
肉类:每天需要半个手掌大小、1cm厚左右的瘦肉,还有一个鸡蛋
大豆和坚果的营养价值较为接近,可以相互替换;每天至少需要摄入一袋牛奶,几片豆腐或者一杯豆浆或者一小把坚果~
咖啡、奶茶、可乐等糖分超标,过量食用对身体有害,压力大的时候不要通过暴饮暴食或者吃甜食缓解,会引发肥胖,而且血糖的突然升高和降低会造成人的焦虑不安,影响工作效率~
燕麦片、杂粮粥、水果沙拉(少吃沙拉酱)、酸奶等都是很健康的饮食~
吃一些深色蔬菜、肝脏、蛋黄补充维生素A,日照合成人体维生素D~
运动:
正确的运动量:每周至少进行5天中等强度的身体活动,每次半小时以上,即每周运动量要在150min以上~

继续阅读[note] 知乎course – 上班族的极简健康课

iPad + Magic Keyboard蓝牙键盘的快捷键~

App页面长按command可以看到所有快捷键的提示~下面是一些常用的~

切换输入法:Control + 空格

切换到上一个应用:Command + Tab(按住可看到打开的所有应用)

中英文输入法切换键:Caps lock

回到主屏幕:command + H

唤出底部程序坞:option + command + D

Spotlight搜索:Command + 空格

还有一些app里面带的快捷键也很好用,长按command就能看见啦~

如何在Dev-Cpp中使用C++11中的函数:stoi、to_string、unordered_map、unordered_set、auto

如果想要在Dev-Cpp里面使用C++11特性的函数,比如刷算法中常用的stoi、to_string、unordered_map、unordered_set、auto这些,需要在设置里面让dev支持c++11~需要这样做~

在工具-编译选项-编译器-编译时加入这个命令“-std=c++11”:

然后就可以愉快的用这些好用到飞起的C++11函数啦啦啦啦啦啦~~~

[C++] STL库函数之字符串string::npos的介绍,以及string中的find函数~

npos经常和find一起用~它们两个都在头文件<string>里面~先看用法:

简单点说就是,在字符串s中查找“b”字符(当然也可以查找一个字符串如“ab”),find函数如果找到了,就会返回第一次出现这个字符的位置,如果没找到怎么办呢,它会返回npos这个位置,npos本质上其实是一个常数,一般来说值是-1,所以s.find(“b”) != string::npos表示找到了“b”这个字符~如果相等就是没找到的意思啦~


我们可以从C++库函数的官方文档(www.cplusplus.com)中找到对这两个函数的解释~

std::string::find——[Return Value]
The position of the first character of the first match.
If no matches were found, the function returns string::npos.

std::string::npos
static const size_t npos = -1;
As a return value, it is usually used to indicate no matches.

以及关于为什么npos的值是-1的解释:

npos is a static member constant value with the greatest possible value for an element of type size_t.
This constant is defined with a value of -1, which because size_t is an unsigned integral type, it is the largest possible representable value for this type.

PAT 1148 Werewolf – Simple Version – 甲级

Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,

player #1 said: “Player #2 is a werewolf.”;
player #2 said: “Player #3 is a human.”;
player #3 said: “Player #4 is a werewolf.”;
player #4 said: “Player #5 is a human.”; and
player #5 said: “Player #4 is a human.”.
Given that there were 2 werewolves among them, at least one but not all the werewolves were lying, and there were exactly 2 liers. Can you point out the werewolves?

Now you are asked to solve a harder version of this problem: given that there were N players, with 2 werewolves among them, at least one but not all the werewolves were lying, and there were exactly 2 liers. You are supposed to point out the werewolves.

Input Specification:
Each input file contains one test case. For each case, the first line gives a positive integer N (5≤N≤100). Then N lines follow and the i-th line gives the statement of the i-th player (1≤i≤N), which is represented by the index of the player with a positive sign for a human and a negative sign for a werewolf.

Output Specification:
If a solution exists, print in a line in ascending order the indices of the two werewolves. The numbers must be separated by exactly one space with no extra spaces at the beginning or the end of the line. If there are more than one solution, you must output the smallest solution sequence — that is, for two sequences A=a[1],…,a[M] and B=b[1],…,b[M], if there exists 0≤k[k+1]<b[k+1], then A is said to be smaller than B. In case there is no solution, simply print No Solution.

Sample Input 1:
5
-2
+3
-4
+5
+4
Sample Output 1:
1 4
Sample Input 2:
6
+6
+3
+1
-5
-2
+4
Sample Output 2 (the solution is not unique):
1 5
Sample Input 3:
5
-2
-3
-4
-5
-1
Sample Output 3:
No Solution

题目大意:已知 N 名玩家中有 2 人扮演狼人角色,有 2 人说的不是实话,有狼人撒谎但并不是所有狼人都在撒谎。要求你找出扮演狼人角色的是哪几号玩家,如果有解,在一行中按递增顺序输出 2 个狼人的编号;如果解不唯一,则输出最小序列解;若无解则输出 No Solution~

分析:每个人说的数字保存在v数组中,i从1~n、j从i+1~n遍历,分别假设i和j是狼人,a数组表示该人是狼人还是好人,等于1表示是好人,等于-1表示是狼人。k从1~n分别判断k所说的话是真是假,k说的话和真实情况不同(即v[k] * a[abs(v[k])] < 0)则表示k在说谎,则将k放在lie数组中;遍历完成后判断lie数组,如果说谎人数等于2并且这两个说谎的人一个是好人一个是狼人(即a[lie[0]] + a[lie[1]] == 0)表示满足题意,此时输出i和j并return,否则最后的时候输出No Solution~