A - Combination Lock
题意:
给两个密码,为最小多少次能吻合。
思路:
对于每一位设a
#include
using namespace std;
int main()
{
int n;
char x[1234],y[1234];
while(cin>>n)
{
scanf("%s%s",x,y);
int ans...
分类:
其他好文 时间:
2015-05-04 10:07:11
阅读次数:
129
接上篇使用RCU技术实现读写线程无锁,在没有GC机制的语言中,要实现Lock free的算法,就免不了要自己处理内存回收的问题。
Hazard Pointer是另一种处理这个问题的算法,而且相比起来不但简单,功能也很强大。锁无关的数据结构与Hazard指针中讲得很好,Wikipedia Hazard pointer也描述得比较清楚,所以我这里就不讲那么细了。
一个简单的实现可以参考我的gith...
分类:
其他好文 时间:
2015-05-03 22:11:14
阅读次数:
158
之前用 Windows, 习惯了 Win+L 的快捷键锁屏, 暂时离开电脑时可以很方便的锁定机器避免被人恶搞, 最主要还是一个安全的习惯. 但是换 MacBook 后遇到的大问题之一就是没找到锁屏快捷键... Cmd+L 啥都不是, 尝试过的方法包括
合上盖子
如同 Windows 的笔记本, 合上盖子实际上并不是锁定 (Lock screen), 而是进入睡眠 (Sleep), 这样...
分类:
系统相关 时间:
2015-05-03 20:39:16
阅读次数:
221
JKLLockScreenViewControllerhttps://github.com/tiny2n/JKLLockScreenViewControllerOverviewIt is Lock Screen Controller on platform iOS.这是iOS平台上的锁屏控制器源码....
分类:
其他好文 时间:
2015-05-02 23:18:50
阅读次数:
261
感觉这次的题目顺序很不合理啊...A. Combination LockScrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to pu.....
分类:
其他好文 时间:
2015-05-02 20:41:04
阅读次数:
197
DescriptionEdward, a poor copy typist, is a user of the Dvorak Layout. But now he has only a QWERTY Keyboard with a broken Caps Lock key, so Edward n....
分类:
其他好文 时间:
2015-05-02 20:40:57
阅读次数:
278
一. lock可以代替synchronized关键字实现互斥功能。使用方法如下:
Lock l = ...;
l.lock();
try {
// access the resource protected by this lock
} finally {
l.unlock();
}
需要注意的是。
1.需要...
分类:
编程语言 时间:
2015-05-02 11:13:30
阅读次数:
157
题目传送门 1 /* 2 贪心水题:累加到目标数字的距离,两头找取最小值 3 */ 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 10 const int MAXN = 1e3 + 10;11...
分类:
其他好文 时间:
2015-05-01 19:54:03
阅读次数:
127
题目传送:Codeforces Round #301 (Div. 2)
A. Combination Lock
水题,求最小移动次数,简单贪心一下即可
AC代码:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#inclu...
分类:
其他好文 时间:
2015-05-01 12:09:59
阅读次数:
217
A - Combination Lock
题目大意:给有n个(0-9)环圈密码锁,数串 s1->s2最少移动次数;
题目分析:
简单模拟;
代码:
const int N=100007;
char s1[N],s2[N];
int main()
{
int n;
while(scanf("%d",&n)==1)
{
int ans=0;
...
分类:
其他好文 时间:
2015-05-01 12:07:42
阅读次数:
185