总之就是线性基那一套贪心理论直接做就好了。

然而加强数据后很卡精度的样子。

于是重点在于这个特技:在整数模意义下搞。

#include<cstdio>
#include<algorithm>
#define N 505
using std::sort;
int k,l,m,n,p=1e9+7;
int s[N],t[N];
int a[N][N],*v[N];
int pow(int u,int v){
	int a=1;
	for(;v;v>>=1){
		if(v&1)
			a=1ll*a*u%p;
		u=1ll*u*u%p;
	}
	return a;
}
bool ovo(int i,int j){
	return s[i]<s[j];
}
bool add(int k){
	for(int i=1;i<=m;++i){
		if(!a[k][i])continue;
		if(!v[i])
			return v[i]=a[k];
		else{
			long long u=p-pow(
			v[i][i],p-2)
			*1ll*a[k][i]%p;
			for(int j=m;j>=i;--j)
				a[k][j]=(a[k]
				[j]+u*v[i][j])%p;
		}
	}
	return 0;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			scanf("%d",a[i]+j);
	for(int i=1;i<=n;++i)
		scanf("%d",s+i);
	for(int i=1;i<=n;++i)
		t[i]=i;
	sort(t+1,t+n+1,ovo);
	for(int i=1;i<=n;++i)
		if(add(t[i]))
			++k,l+=s[t[i]];
	printf("%d %d\n",k,l);
}

  

BZOJ4004: [JLOI2015]装备购买的更多相关文章

  1. 【题解】 bzoj4004: [JLOI2015]装备购买 (线性基)

    bzoj4004,戳我戳我 Solution: 裸的线性基,这没啥好说的,我们说说有意思的地方(就是我老是wa的地方) Attention: 这题在\(luogu\),上貌似不卡精度,\(bzoj\) ...

  2. [BZOJ4004][JLOI2015]装备购买(贪心+线性基)

    求最小权极大线性无关组. 先将所有向量按权值排序,从小到大依次判断,若能被前面已选向量线性表出则不选,这样一定最优. 据说是用拟阵来证明,但感性理解一下感觉比较显然,首先这样个数一定是最多的,其次对于 ...

  3. bzoj4004 [JLOI2015]装备购买——线性基+贪心

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4004 今天讲课讲到的题,据说满足拟阵的性质,所以贪心是正确的: 总之就贪心,按价格从小到大排 ...

  4. BZOJ4004 [JLOI2015]装备购买[贪心+线性基+高消]

    一个物品可以被其他物品表出,说明另外的每个物品看成矩阵的一个行向量可以表出该物品代表的行向量. 于是构造矩阵,求最多选多少个物品,就是尽可能用已有的物品去表示,相当于去消去一些没必要物品, 类似于xo ...

  5. 【BZOJ4004】[JLOI2015]装备购买 贪心+高斯消元

    [BZOJ4004][JLOI2015]装备购买 Description 脸哥最近在玩一款神奇的游戏,这个游戏里有 n 件装备,每件装备有 m 个属性,用向量zi(aj ,.....,am) 表示 ( ...

  6. bzoj 4004: [JLOI2015]装备购买 拟阵 && 高消

    4004: [JLOI2015]装备购买 Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 337  Solved: 139[Submit][Status ...

  7. BZOJ_4004_[JLOI2015]装备购买_线性基

    BZOJ_4004_[JLOI2015]装备购买_线性基 Description 脸哥最近在玩一款神奇的游戏,这个游戏里有 n 件装备,每件装备有 m 个属性,用向量zi(aj ,.....,am) ...

  8. [JLOI2015]装备购买 (高斯消元)

    [JLOI2015]装备购买 \(solution:\) 首先这道题的题面已经非常清晰的告诉我们这就是线性空间高斯消元的一道题(可以用某些装备来表示另一件装备,这已经不能再明显了),只是这道题要求我们 ...

  9. BZOJ 4004: [JLOI2015]装备购买

    4004: [JLOI2015]装备购买 Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 1154  Solved: 376[Submit][Statu ...

随机推荐

  1. UTF-8和Unicode

    What's the difference between unicode and utf8? up vote 103 down vote favorite 49 Is it true that un ...

  2. SSH登录之后运行命令报错的解决办法-- Failed to connect to Mir: Failed to connect to server socket: No such file or directory

    问题描述: Failed to connect to Mir: Failed to connect to server socket: No such file or directory 解决方案: ...

  3. mysql创建触发器

    触发器语句只有一句话 可以省略begin和end CREATE trigger `do_praise` after insert on praise for each row update post ...

  4. Ubuntu安装出现左上角光标一直闪解决方式

    Ubuntu安装出现左上角光标一直闪解决方式: 01下载ubunu http://cn.ubuntu.com/download/ 02.软碟通 http://pan.baidu.com/s/1qY8O ...

  5. android SwipeRefreshLayout google官方下拉刷新控件

    下拉刷新功能之前一直使用的是XlistView很方便我前面的博客有介绍 SwipeRefreshLayout是google官方推出的下拉刷新控件使用方法也比较简单 今天就来使用下SwipeRefres ...

  6. 十天冲刺---Day9

    站立式会议 站立式会议内容总结: 燃尽图 照片 队员们都回来了,写完之后继续对alpha版本进行迭代. 希望演示的时候能拿得出来.

  7. mybatis Generator配置文件详解

    这里按照配置的顺序对配置逐个讲解,更细的内容可以配合中文文档参照. 1. 配置文件头 <?xml version="1.0" encoding="UTF-8&quo ...

  8. 链栈的C语言实现

    /* 功能:栈的链表实现 Author:lxm Date: 20160511 */ #include <stdio.h> #include <stdlib.h> #define ...

  9. Region-Based Segmentation

    读完10.4 Region-Based Segmentation这一小节, 新get到的且需要留意的知识点: Region Spltting and Merging, quadtrees Waters ...

  10. list 集合

    1.Model public class ROLE_FUNCTION { //角色集合 public List< ROLE> ROLES { get; set; } //角色权限集合 pu ...