题目: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. Python 2:str.title()(使字符串每个单词首字母大写)

    name = "hello,world! hello,python!" print(name.title()) #单词首字母大写 运行结果将会是:Hello,World!Hello ...

  2. mysql数据库的介绍及安装

    一.什么是数据库 1.什么是数据(Data) 描述事物的符号记录成为数据,描述事物的符号既可以是文字.图片.图像.声音.语言等,数据有多种表现形式,他们都可以经过数字化后存入计算机 在计算机中描述一个 ...

  3. B - Is your horseshoe on the other hoof?

    Problem description Valera the Horse is going to the party with friends. He has been following the f ...

  4. C - Arrival of the General

    Problem description A Ministry for Defense sent a general to inspect the Super Secret Military Squad ...

  5. MyEclipse获取注册码

    最近刚装上MyEclipse,一直弹窗提示注册码过期,开始还能接受,到最后,每发布一个项目便弹窗提醒,顿时感觉烦了,得治理治理这个烦人的注册码,下面是一段自动生成注册名和注册码的代码,只需要直接拿来用 ...

  6. [Intermediate Algorithm] - Steamroller

    题目 对嵌套的数组进行扁平化处理.你必须考虑到不同层级的嵌套. 提示 Array.isArray() 测试用例 steamroller([[["a"]], [["b&qu ...

  7. Java导出Excel(附完整源码)

    导出excel是咱Java开发的必备技能啦,之前项目有这个功能,现在将其独立出来,分享一下.所用技术就是SpringBoot,然后是MVC架构模式.废话不多说,直接上代码了,源码点末尾链接就可以下载. ...

  8. 在Unity中客户端与服务器端的2种通信方式(Socker)

    15:17 2019/5/10 //第一种 using UnityEngine; using System.Collections; //引入库 using System.Net; using Sys ...

  9. 【转载】Jmeter分布式部署测试-----远程连接多台电脑做压力性能测试

    在使用Jmeter进行接口的性能测试时,由于Jmeter 是JAVA应用,对于CPU和内存的消耗比较大,所以,当需要模拟数以万计的并发用户时,使用单台机器模拟所有的并发用户就有些力不从心,甚至会引起J ...

  10. 【第一课】kaggle初识

    Evernote Export Crowdflower搜索结果相关性 文件和数据描述 train.csv训练数据集包括: id:产品ID查询:使用的搜索词 product_description:完整 ...