题目: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的更多相关文章

  1. SRM 622 D2L3: Subsets, math, backtrack

    题目:http://community.topcoder.com/stat?c=problem_statement&pm=10554&rd=15855 符合条件的集中非1的元素个数是非 ...

  2. SRM 620 D2L3: RandomGraph, dp

    称号:http://community.topcoder.com/stat? c=problem_statement&pm=13143&rd=15853 參考:http://apps. ...

  3. SRM 624 D2L3: GameOfSegments, 博弈论,Sprague–Grundy theorem,Nimber

    题目:http://community.topcoder.com/stat?c=problem_statement&pm=13204&rd=15857 这道题目须要用到博弈论中的经典理 ...

  4. SRM 628 D1L3:DoraemonPuzzleGame,math,后市展望,dp

    称号:c=problem_statement&pm=13283&rd=16009">http://community.topcoder.com/stat?c=probl ...

  5. 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)数列所有 ...

  6. Java实现 LeetCode 621 任务调度器(暴力大法)

    621. 任务调度器 给定一个用字符数组表示的 CPU 需要执行的任务列表.其中包含使用大写的 A - Z 字母表示的26 种不同种类的任务.任务可以以任意顺序执行,并且每个任务都可以在 1 个单位时 ...

  7. JavaScript中Math对象的方法介绍

    1.比较最值方法 比较最值有两种方法,max() 和 min() 方法. 1.1 max() 方法,比较一组数值中的最大值,返回最大值. var maxnum = Math.max(12,6,43,5 ...

  8. JavaScript Math和Number对象

    目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...

  9. Chrome V8引擎系列随笔 (1):Math.Random()函数概览

    先让大家来看一幅图,这幅图是V8引擎4.7版本和4.9版本Math.Random()函数的值的分布图,我可以这么理解 .从下图中,也许你会认为这是个二维码?其实这幅图告诉我们一个道理,第二张图的点的分 ...

随机推荐

  1. SpringCloud(二) 服务注册与发现Eureka

    1.eureka是干什么的? 上篇说了,微服务之间需要互相之间通信,那么通信就需要各种网络信息,我们可以通过使用硬编码的方式来进行通信,但是这种方式显然不合适,不可能说一个微服务的地址发生变动,那么整 ...

  2. Java调用JavaWebService

    1.pom配置 <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId&g ...

  3. TopK代码

    Hash表 #ifndef _HASH_H #define _HASH_H #include<string.h> #include<stdio.h> class HashTab ...

  4. 树莓派-基于raspistill实现定时拍照

    raspistill 经过上一篇<<树莓派-安装摄像头模块>>之后 raspistill 是树莓派基于摄像头拍照命令 比如我要截取一张宽1024px,高768px,旋转180度 ...

  5. Android MediaRecorder自定义分辨率

    Android MediaRecorder自定义分辨率 工作这么久了,确实积累了不少东西,但都是以文档的形式存在U盘里的,为什么不写博客呢?因为懒啊!!!总感觉博客太难写了(大概是上学时候写作文恐惧症 ...

  6. Leetcode0002--Add Two Numbers 链表求和

    [转载请注明]http://www.cnblogs.com/igoslly/p/8672467.html 来看一下题目: You are given two non-empty linked list ...

  7. Leetcode0100--Same Tree 相同树

    [转载请注明]http://www.cnblogs.com/igoslly/p/8707664.html 来看一下题目: Given two binary trees, write a functio ...

  8. js date 转化为字符串函数

    getDate() 从 Date 对象返回一个月中的某一天 (1 ~ 31). getDay() 从 Date 对象返回一周中的某一天 (0 ~ 6). getFullYear() 从 Date 对象 ...

  9. 【SQL】结构化查询语言

    一:数据查询语言(DQL:Data Query Language): 其语句,也称为“数据检索语句”,用以从表中获得数据,确定数据怎样在应用程序给出.保留字SELECT是DQL(也是所有SQL)用得最 ...

  10. 安卓代码迁移:Make.exe: *** [libs/armabi-v7a/gdbserver] Error 1

    解决办法1:安装ndk和eclipse修改为x86操作系统 解决办法2:降低更换NDK版本