Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

同样是打表,这个表可以用一行代码生成

Posted by Eov_Second at 2016-12-16 14:27:42 on Problem 2895
在一个按键上的字符分为一个组,正好8个组,占3bit,而一个组里最多4个字母,占2bit。例如字母H,位于第三组,组号是010(000算第一个),在组里排行第二,序号是01,所以对应的二进制01001,也就是数字9。因此,表格就是
char table[] = {0,1,2,4,5,6,8,9,10,12,13,14,16,17,18,20,21,22,23,24,25,26,28,29,30,31};

由于是连续的自然数,并且逢被4除余3的数就跳过(23,31特判),可以考虑用循环来生成表格

for(index=0,b=0;index<25;b%4!=3?0:b!=23?b++:0)
  table[index++]=b++;
table[index]=31

后面用位运算查表就好了,对每一个字符先获取组内排名,计算按键时间,然后再查表获取组号,和上一个组相同的话,加一个等待时间。

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator