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()函数的值的分布图,我可以这么理解 .从下图中,也许你会认为这是个二维码?其实这幅图告诉我们一个道理,第二张图的点的分 ...
随机推荐
- 题解报告:hdu 1847 Good Luck in CET-4 Everybody!(入门SG值)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1847 Problem Description 大学英语四级考试就要来临了,你是不是在紧张的复习?也许紧 ...
- js基础---字符串方法
// var str1="xudandan"; // 字符串长度 var str1_length=str1.length;console.log(str1);console.log ...
- (转)Vue 爬坑之路(一)—— 使用 vue-cli 搭建项目
vue-cli 是一个官方发布 vue.js 项目脚手架,使用 vue-cli 可以快速创建 vue 项目,GitHub地址是:https://github.com/vuejs/vue-cli 一. ...
- (转) 前端模块化:CommonJS,AMD,CMD,ES6
模块化的开发方式可以提高代码复用率,方便进行代码的管理.通常一个文件就是一个模块,有自己的作用域,只向外暴露特定的变量和函数.目前流行的js模块化规范有CommonJS.AMD.CMD以及ES6的模块 ...
- WinXP SSH连接不上虚拟机的解决方法
问题现象描述: 在VMWare中安装好linux系统后,选择桥接,从宿主机Windows上使用Putty, SSH Secure Shell等客户端工具连接linux上的ssh服务,客户端一直没有反应 ...
- CNN结构:用于检测的CNN结构进化-分离式方法
前言: 原文链接:基于CNN的目标检测发展过程 文章有大量修改,如有不适,请移步原文. 参考文章:图像的全局特征--用于目标检测 目标的检测和定位中一个很困难的问题是,如何从数以万计的候选 ...
- VR: AR和VR演进哲学
Facebook 20亿美元(4亿美元+16亿美元股票换购方式)收购虚拟现实厂商Oculus 引爆AR产业,索尼不温不火逐步演进的头盔项目也该加速了.最近Oculus rift发布了商业版本:Ocul ...
- 创建一个类Person
创建一个类Person,包含以下属性:姓名(name).年龄(age).朋友(friends数组).问候(sayhi方法,输出问候语,例如:"你好!").交朋友(addFriend ...
- (转)openlayers实现在线编辑
http://blog.csdn.net/gisshixisheng/article/details/46054949 概述: 在前面有篇博文讲述了基于Arcgis for js和wkt实现在线数据的 ...
- 进行https通信时服务器端下发的是一个证书链
进行https通信时服务器端下发的是一个证书链,否则无法验证证书的有效性.