2013年8月13日
摘要: ^_^#include #include #include using namespace std;#define M 500002int mu[M],d[M];int lis(int n) //n*lg(n){ d[1] = mu[1]; int len = 1; for(int i=2; i> 1; if(d[mid] len) len++; } return len;}int main(int argc, char* argv[]){#ifdef __MYLOCAL freopen("in.txt","r",stdin);#en... 阅读全文
posted @ 2013-08-13 13:35 lk1993 阅读(168) 评论(0) 推荐(0) 编辑
摘要: #include #include #define M 1002char map[M][220] = {"0","1","1"};void add(char *aStr, char *bStr, char *cStr)//aStr + bStr = cStr{ int ai = strlen(aStr)-1,bi = strlen(bStr)-1,ci = 0; int all,over = 0; for(; ai>=0 || bi>=0; ai--,bi--) { all = (ai>=0 ? aStr[ai]-& 阅读全文
posted @ 2013-08-13 13:30 lk1993 阅读(171) 评论(0) 推荐(0) 编辑
  2013年8月11日
摘要: 需要注意特殊案例的是:最后走到入口出时,步数为 0 。#include #include #define M 12char move_map[4] = {'N','S','E','W'};int move_do[4][2] = {-1,0,1,0,0,1,0,-1};char map[M][M];int step[M][M];int row,col,in,re_step,re_round;int jud(int r, int c){ if(rrow-1 || ccol-1) return 0; return 1;}void dfs 阅读全文
posted @ 2013-08-11 19:31 lk1993 阅读(175) 评论(0) 推荐(0) 编辑
  2013年8月9日
摘要: 最长公共子序列对于两个字符串 ic,id , 我们定义 dp[i][j] 数组来表示 ic 的第 i-1 个字符与 id 的第 j-1 个字符的公共序列长度。由于数组从 0 开始, 状态转移方程为 dp[i+1][j+1] = dp[i][j] + 1 ic[i] == id[j] dp[i+1][j+1] =max(dp[i+1][j],dp[i][j+1]) ic[i] != id[j]#include #include #define M 1002#define max(a,b) ((a) >= (b) ? (a) : (b))int... 阅读全文
posted @ 2013-08-09 20:42 lk1993 阅读(161) 评论(0) 推荐(0) 编辑
  2013年8月8日
摘要: while(sc.hasNext()) {} 多案例stripTrailingZeros() 去除后导零toPlainString() 变换到 String 中,防止以科学计数输出import java.math.*;import java.util.*;public class Main{ public static void main(String[] args) { BigDecimal a; int n; String p; Scanner sc = new Scanner(System.in); ... 阅读全文
posted @ 2013-08-08 16:47 lk1993 阅读(162) 评论(0) 推荐(0) 编辑
  2013年8月7日
摘要: #include #include int main(int argc, char* argv[]){ #ifdef __MYLOCAL freopen("in.txt","r",stdin); #endif int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); int all = 1, a = n % 10; while(n > 0) { n % 2 == 1 ? all = all * a % 10 : NULL; ... 阅读全文
posted @ 2013-08-07 21:33 lk1993 阅读(137) 评论(0) 推荐(0) 编辑
摘要: m = n^n ==> lg(m) = lg(n^n)==> lg(m) = n*lg(n)==> m = 10^(n*lg(n))对于 10^N = 10^123.456 = 10^(123+0.456) = 10^123 * 10^0.0.45610^123 的最高位为 '1',即 10^N 的最高位取决于n*lg(n) 的小数部位#include #include #include int main(int argc, char* argv[]){ #ifdef __MYLOCAL freopen("in.txt","r&q 阅读全文
posted @ 2013-08-07 21:17 lk1993 阅读(447) 评论(0) 推荐(0) 编辑
摘要: b 值大,取二分幂计算#include #include #define Mint main(int argc, char* argv[]){ #ifdef __MYLOCAL freopen("in.txt","r",stdin); #endif int a,b,c,t; while(scanf("%d%d",&a,&b) != EOF) { c = 1, t = a % 10; while(b > 0) { b % 2 == 1 ? c = c * t % 10 : NULL; ... 阅读全文
posted @ 2013-08-07 20:18 lk1993 阅读(171) 评论(0) 推荐(0) 编辑
  2013年8月1日
摘要: 简单入门DP第 i-1 层的 j 列加上第 i 层的 j 列 j+1 列的大值。#include #include #define M 102#define max(a,b) ((a)>(b) ? (a) : (b))int dp[M][M];int run(int n){ for(int i=n; i>=2; i--) { for(int j=1; j<i; j++) dp[i-1][j] += max(dp[i][j],dp[i][j+1]); } return dp[1][1];}int main(int argc, char*... 阅读全文
posted @ 2013-08-01 10:10 lk1993 阅读(219) 评论(0) 推荐(0) 编辑
  2013年7月31日
摘要: 公式: (a+b)%k = (a%k + b%k)%k (a-b)%k = (a%k - b%k)%k#include #include #define M 1000000#define MOD 3int map[M] = {7,11};void init(){ for(int i=2; i<M; i++) { map[i] = (map[i-2] % MOD + map[i-1] % MOD) % MOD; }}int main(int argc, char* argv[]){ #ifdef __MYLOCAL freopen("in.txt"... 阅读全文
posted @ 2013-07-31 19:39 lk1993 阅读(168) 评论(0) 推荐(0) 编辑