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>里面~先看用法:
1 2 3 4 5 6 7 8 9 10 11 |
#include <iostream> #include <string> using namespace std; int main() { string s = "abc"; if (s.find("b") != string::npos) printf("字符串s中存在b字符~"); else printf("字符串s中不存在b字符~"); return 0; } |
简单点说就是,在字符串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~
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#include <iostream> #include <vector> #include <cmath> using namespace std; int main() { int n; cin >> n; vector<int> v(n+1); for (int i = 1; i <= n; i++) cin >> v[i]; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { vector<int> lie, a(n + 1, 1); a[i] = a[j] = -1; for (int k = 1; k <= n; k++) if (v[k] * a[abs(v[k])] < 0) lie.push_back(k); if (lie.size() == 2 && a[lie[0]] + a[lie[1]] == 0) { cout << i << " " << j; return 0; } } } cout << "No Solution"; return 0; } |