# Anchor
click_link 'Save'
# Button
click_button 'awesome'
# Both above
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Takes a credit card string value and returns true on valid number | |
function valid_credit_card(value) { | |
// Accept only digits, dashes or spaces | |
if (/[^0-9-\s]+/.test(value)) return false; | |
// The Luhn Algorithm. It's so pretty. | |
let nCheck = 0, bEven = false; | |
value = value.replace(/\D/g, ""); | |
for (var n = value.length - 1; n >= 0; n--) { |
随便扯一个61A的题目好了(其实是我太懒不想找题...)
不知道你还记得不记得61A的某个MT的leaps那道题。
有一排N个宝藏,从左到右每个宝藏价值分别为vi。地精可以拿走其中一些宝藏,但是不能取相邻的宝藏。求最大价值和。
例如有6个宝藏,价值分别为2 5 2 1 4 1。我可以取2 2 4、5 1 1、5 4等等,但是不能取2 5 2,因为2和5是相邻的。
令f[i]为前i个宝藏中取走若干个所能获得的最大收益
易知,f[1] = v[1],f[2] = max(v[1], v[2])(为什么?)
f[i] = max(f[i-1], f[i-2] + v[i])
answer = f[N]
下面题目中有个别题用到了尚未讲解的知识,但是每一题至少能做出一两步,或者写出一个暴力解。能做到哪做到哪吧。
VIJOS 1102 陶陶摘苹果(NOIp 2005 普及组)
VIJOS 1445 陶陶抢苹果
VIJOS 1291 苹果摘陶陶
(我才不会告诉你还有一道陶陶吃苹果、一道陶陶玩红警呢)
Euler 15 Lattice paths
Euler 67 Maximum path sum II
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */ | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <limits.h> | |
#include <string.h> | |
struct entry_s { | |
char *key; | |
char *value; |