- 博客(11)
- 资源 (2)
- 收藏
- 关注
原创 codeforces--707E. Garlands(二维树状数组)
cf 707E题解参考题解#include <bits/stdc++.h>using namespace std;const double eps = 1E-8;const int dx[4] = {1, 0, 0, -1};const int dy[4] = {0, -1, 1, 0};const int inf = 0x3f3f3f3f;const int N = 1E5 + 7;#
2016-08-26 16:41:48 986
原创 codeforces--707D. Persistent Bookcase
cf 707D题解将每个操作视为一个结点,从而可以构造一棵树,查询则是从根出发遍历整棵树,回溯的过程中不要忘记修改惠原来的状态。#include <bits/stdc++.h>using namespace std;const int maxn = 1000 + 5;const int maxq = 100000 + 5;int n, m, q;bool bookcase[maxn][max
2016-08-26 16:13:16 720
原创 codeforces--707C. Pythagorean Triples
cf 707C题解Wikipedia:勾股数 勾股数的一种构造方法: 若 a=2n+1a = 2n + 1,则 b=2n2+2nb = 2n^2 + 2n,c=b+1c = b + 1; 若 a=2na = 2n,则 b=n2−1b = n^2 - 1,c=n2+1c = n^2 + 1import java.util.Scanner;public class CF707C { publ
2016-08-26 15:31:12 658
原创 codeforces--707B. Bakery
cf 707B题解n个顶点的图,在 k 个顶点和另外 n - k 个顶点中寻一条最短的边。#include <bits/stdc++.h>using namespace std;const double eps = 1E-8;const int dx[4] = {1, 0, 0, -1};const int dy[4] = {0, -1, 1, 0};const int inf = 0x3f
2016-08-26 15:10:06 689
原创 codeforces--707A. Brain's Photos
cf 707A题解import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), m = in.nextInt(); boo
2016-08-26 14:58:41 552
原创 位运算(3)-- 高级运用
注:此文内容来自于对【数据结构与算法之位运算】课程所做的笔记一、二进制中1的个数问题:给定一个无符号整型变量,求其二进制表示中“1”的个数。 相似问题:判断整数A转换成整数B需要的次数。(A ^ B,再求“1”的个数) 分析:很容易想到右移,然后判断奇偶性,复杂度与最左侧的1的位置相关。int oneCount(unsigned int n){ int c = 0; while(
2016-08-14 08:53:27 2069 1
原创 位运算(2)-- 集合中的位运算
一、基本概念当集合元素个数较少时,可以用二进制来表示。集合{0, 1, ..., n - 1}的子集S可以用如下方法编码成整数: f(S)=∑i∈S2if(S) = \sum_{i \in S}{2 ^ i} 本质就是用每一个二进制位来表示某个元素是否出现。空集 ϕ\phi:0只含有第i个元素的集合{i}:1 << i含有全部n个元素的集合{0, 1, ..., n - 1}:(1 <<
2016-08-13 14:24:55 1603
原创 位运算(1)-- 基础
一、基础与:a & b 或:a | b 非:~ a 异或:a ^ b 左移:a << b 右移:a >> b二、基本技巧与操作:指定位清零:void clr(int& a, int i) { a &= ~(1 << i); }获取指定位的值:int get(int a, int i) { return a & (1 << i); }保留某些位不变:操作数相应的要保留的位设置位1,如:
2016-08-12 21:41:56 533
原创 leetcode--17. Letter Combinations of a Phone Number
Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) i
2016-08-07 13:00:13 288
原创 leetcode--016. 3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly
2016-08-02 19:51:40 442
原创 leetcode--015. 3Sum
3Sum题意给一个含有n个整数的数组S, 数组中是否存在三个数,a, b, c 使 a + b + c = 0,找出所有这样的唯一的三元组(a, b, c)。题解对每一个nums[i],在区间[i + 1, n - 1]寻找。class Solution {public: vector<vector<int>> threeSum(vector<int>& nums) { v
2016-08-02 19:49:18 321
蓝桥杯2014年C语言真题
2015-02-02
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人