SRM 621 D2L3: MixingColors, math
题目:http://community.topcoder.com/stat?
c=problem_statement&pm=10409&rd=15854
利用高斯消元求线性空间的基,也就是求矩阵的秩。
代码:
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <iostream>
#include <sstream>
#include <iomanip> #include <bitset>
#include <string>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map> #include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std; #define CHECKTIME() printf("%.2lf\n", (double)clock() / CLOCKS_PER_SEC)
typedef pair<int, int> pii;
typedef long long llong;
typedef pair<llong, llong> pll;
#define mkp make_pair
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); ++it) /*************** Program Begin **********************/ class MixingColors {
public:
int minColors(vector <int> colors) {
int res = 0;
int n = colors.size();
bool used[55];
memset(used, 0, sizeof(used)); for (int i = 31; i >= 0; i--) {
int pivot = 0;
for (int j = 0; j < n; j++) {
if (used[j]) {
continue;
}
if ((colors[j] >> i) & 0x1) {
if (!pivot) {
pivot = colors[j];
used[j] = true;
++res;
} else {
colors[j] ^= pivot;
}
}
}
} return res;
}
}; /************** Program End ************************/
SRM 621 D2L3: MixingColors, math的更多相关文章
- SRM 622 D2L3: Subsets, math, backtrack
题目:http://community.topcoder.com/stat?c=problem_statement&pm=10554&rd=15855 符合条件的集中非1的元素个数是非 ...
- SRM 620 D2L3: RandomGraph, dp
称号:http://community.topcoder.com/stat? c=problem_statement&pm=13143&rd=15853 參考:http://apps. ...
- SRM 624 D2L3: GameOfSegments, 博弈论,Sprague–Grundy theorem,Nimber
题目:http://community.topcoder.com/stat?c=problem_statement&pm=13204&rd=15857 这道题目须要用到博弈论中的经典理 ...
- SRM 628 D1L3:DoraemonPuzzleGame,math,后市展望,dp
称号:c=problem_statement&pm=13283&rd=16009">http://community.topcoder.com/stat?c=probl ...
- SRM144 - SRM 148(少144-DIV1-LV3,147-DIV2-LV3)
SRM 144 DIV 1 500pt tag:组合 题意:彩票中奖.给定n, m,从1-n中选择m个数组成数列a1, a2, a3...am.对于数列{am}分别满足以下条件的概率: (1)数列所有 ...
- Java实现 LeetCode 621 任务调度器(暴力大法)
621. 任务调度器 给定一个用字符数组表示的 CPU 需要执行的任务列表.其中包含使用大写的 A - Z 字母表示的26 种不同种类的任务.任务可以以任意顺序执行,并且每个任务都可以在 1 个单位时 ...
- JavaScript中Math对象的方法介绍
1.比较最值方法 比较最值有两种方法,max() 和 min() 方法. 1.1 max() 方法,比较一组数值中的最大值,返回最大值. var maxnum = Math.max(12,6,43,5 ...
- JavaScript Math和Number对象
目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...
- Chrome V8引擎系列随笔 (1):Math.Random()函数概览
先让大家来看一幅图,这幅图是V8引擎4.7版本和4.9版本Math.Random()函数的值的分布图,我可以这么理解 .从下图中,也许你会认为这是个二维码?其实这幅图告诉我们一个道理,第二张图的点的分 ...
随机推荐
- POJ 1160 DP
题目: poj 1160 题意: 给你n个村庄和它的坐标,现在要在其中一些村庄建m个邮局,想要村庄到最近的邮局距离之和最近. 分析: 这道题.很经典的dp dp[i][j]表示建第i个邮局,覆盖到第j ...
- layer的基本使用
layer是layui独立出来的一个弹出层模块 <!DOCTYPE html> <html> <head> <meta charset="UTF-8 ...
- UML基本关系
UML-Unified Model Language 统一建模语言,又称标准建模语言.是用来对软件密集系统进行可视化建模的一种语言.UML的定义包括UML语义和UML表示法两个元素. UML是在开发阶 ...
- Laravel5.1学习笔记8 Blade模板
简介 模板继承 定义一个页面布局模板 扩展一个页面布局模板 展示数据 控制语法的结构 Service Injection 扩展 Blade 简介 Blade 是 Laravel 提供的一个既简单又 ...
- 玩转公众号markdown排版
Md2All 简介 Markdown排版利器,支持 "一键排版" 的样式模板选择,支持"css样式自定义",支持80多种代码高亮. 能让Markdown内容,无 ...
- 【Oracle】OGG(Oracle GoldenGate)简介及搭建过程
GoldenGate公司简介 GoldenGate公司专注于数据同步领域,是实现数据同步技术的领导者.至2007年,在全球35个国家售出超过2000个许可证,客户分布在政府.银行.电信.证券.传媒.医 ...
- 安装Oracle客户端时,检查系统要求时状态为错误的解决办法
这是我自己安装oracle11g至win7的错误记录: 正在检查操作系统要求... 要求的结果: 5.0,5.1,5.2,6.0 之一 实际结果: 6.1 我换了 10g,11g从32bit到64bi ...
- JAVA;使用java.awt.Image的不稳定性
在使用awt的image时候,不是能时时获取到图像的宽和高, GetWidth()函数偶尔得到的值为-1,暂时没有找到解决方法. 代码: public class picture extends JF ...
- Ubuntu安装中文语言包
使用Ubuntu 默认的界面感觉不习惯,于是安装KDE界面. 1.安装kde 使用命令行: sudo apt-get install kubuntu-desktop 安装后发现不能使用中文, 在 se ...
- 团体程序设计天梯赛-练习集-L1-046. 整除光棍
L1-046. 整除光棍 这里所谓的“光棍”,并不是指单身汪啦~ 说的是全部由1组成的数字,比如1.11.111.1111等.传说任何一个光棍都能被一个不以5结尾的奇数整除.比如,111111就可以被 ...