上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 43 下一页
摘要: https://www.hackerrank.com/contests/w1/challenges/maximizing-xor/找了半天规律,答案竟然是暴力,伤感。我找到的方法是利用规律2^x XOR 2^x - 1会最大,感觉稍微效率高点。int maxXor(int l, int r) { i... 阅读全文
posted @ 2014-08-16 01:24 阿牧遥 阅读(285) 评论(0) 推荐(0) 编辑
摘要: https://www.hackerrank.com/contests/w2/challenges/cut-the-tree树分成两部分,求两部分差最小。一开始想多了,后来其实求一下总和,求一下分部的和就行了。#include #include #include #include #include ... 阅读全文
posted @ 2014-08-16 00:05 阿牧遥 阅读(317) 评论(0) 推荐(0) 编辑
摘要: https://www.hackerrank.com/contests/w2/challenges/manasa-and-stones简单题。#includeusing namespace std;int main() { int T; cin >> T; while (T--) ... 阅读全文
posted @ 2014-08-15 20:22 阿牧遥 阅读(178) 评论(0) 推荐(0) 编辑
摘要: https://www.hackerrank.com/contests/w3/challenges/sam-and-substringsDP。注意到以N[i]结尾的每个字符串的子数字和有规律:53125 | 3 53 | 1 31 531 | 2 12 312 5312sd[2] = 1 + 31 ... 阅读全文
posted @ 2014-08-14 18:19 阿牧遥 阅读(399) 评论(0) 推荐(1) 编辑
摘要: https://www.hackerrank.com/contests/w3/challenges/the-love-letter-mystery简单题。#include #include #include using namespace std;int main() { int N; cin >>... 阅读全文
posted @ 2014-08-14 15:46 阿牧遥 阅读(198) 评论(0) 推荐(0) 编辑
摘要: https://www.hackerrank.com/contests/w4/challenges/crush第一眼觉得要用线段树,但据说会超时。其实这个可以通过生成pair排序来做。#include #include #include #include using namespace std;in... 阅读全文
posted @ 2014-08-14 15:20 阿牧遥 阅读(329) 评论(0) 推荐(0) 编辑
摘要: 简单题。#include #include using namespace std;int main() { int T; cin >> T; while (T--) { string s; cin >> s; int l = 0; ... 阅读全文
posted @ 2014-08-14 00:08 阿牧遥 阅读(210) 评论(0) 推荐(0) 编辑
摘要: https://www.hackerrank.com/contests/w5/challenges/closest-number简单题。#include #include using namespace std;int main() { int T; cin >> T; while... 阅读全文
posted @ 2014-08-13 18:24 阿牧遥 阅读(255) 评论(0) 推荐(0) 编辑
摘要: https://www.hackerrank.com/contests/w5/challenges简单题,注意整数的0次方是1,奇数。#include #include using namespace std;int main() { int N; cin >> N; vector... 阅读全文
posted @ 2014-08-13 17:23 阿牧遥 阅读(288) 评论(0) 推荐(0) 编辑
摘要: https://www.hackerrank.com/contests/w6/challenges/consecutive-subsequences求数组中被k整除的子段和有几个。这个要利用sum[i..j] = sum[j] - sum[i-1],注意这样还要保留一个sum[-1]=0(根据下标的... 阅读全文
posted @ 2014-08-13 13:28 阿牧遥 阅读(433) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 43 下一页