SRM 554

矩阵连乘

本以为很开心的一道题,矩阵构造太难写了。。

 0.  1.  2.  2.  3.  3.  4.  4.  4.  4.  5.  6.
 ab  ab  ab  aa  ab  ab  ab  ab  aa  ac  aa  aa
 cd  ba  ab  bb  ca  bc  ac  cb  cb  bb  aa  ab
这是我人肉的7中情况。。。然后。。。额。。。写了一下午。。。


叉姐好神啊!他貌似先求了4的最小表示,在求了8的最小表示然后。。。


我大概人肉了这7种情况的最小表示,然后枚举了剩下4个的最小表示?反正写的它麻麻都不认识他了。。。

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

class TheBrickTowerHardDivOne {
public:
	int find(int, int, long long);
};
/*
 0.  1.  2.  2.  3.  3.  4.  4.  4.  4.  5.  6.
 ab  ab  ab  aa  ab  ab  ab  ab  aa  ac  aa  aa
 cd  ba  ab  bb  ca  bc  ac  cb  cb  bb  aa  ab
 0->0
 */
int f[7][4] = { { 0, 1, 2, 3 }, { 0, 1, 1, 0 }, { 0, 1, 0, 1 }, { 0, 1, 2, 0 },
		{ 0, 1, 0, 2 }, { 0, 0, 0, 0 }, { 0, 0, 0, 1 } };
int id[7][8];
long long a[66][66], t[66][66], tmp[66][66];
int b[4];
bool flag[10];
int ed;
long long pmod = 1234567891;
void mul(long long a[][66], long long b[][66]) {
	int i, j, k;
	memset(tmp, 0, sizeof(tmp));
	for (i = 0; i < ed; ++i) {
		for (j = 0; j < ed; ++j) {
			for (k = 0; k < ed; ++k) {
				tmp[i][j] += a[i][k] * b[k][j] % pmod;
				tmp[i][j] %= pmod;
			}
		}
	}
	for (i = 0; i < ed; ++i) {
		for (j = 0; j < ed; ++j)
			a[i][j] = tmp[i][j];
	}
}
int TheBrickTowerHardDivOne::find(int C, int K, long long H) {
	int i, j, k, p;
	ed = 0;
	for (i = 0; i < 7; ++i) {
		for (j = 0; j <= K; ++j) {
			id[i][j] = ed;
			ed++;
		}
	}
	memset(a, 0, sizeof(a));
	for (i = 0; i < 7; ++i) {
		for (b[0] = 0; b[0] < 8; ++b[0]) {
			for (b[1] = 0; b[1] < 8; ++b[1]) {
				for (b[2] = 0; b[2] < 8; ++b[2]) {
					for (b[3] = 0; b[3] < 8; ++b[3]) {
						if (f[i][0] >= C)
							continue;
						if (f[i][1] >= C)
							continue;
						if (f[i][2] >= C)
							continue;
						if (f[i][3] >= C)
							continue;
						if (b[0] >= C)
							continue;
						if (b[1] >= C)
							continue;
						if (b[2] >= C)
							continue;
						if (b[3] >= C)
							continue;

						memset(flag, false, sizeof(flag));
						long long v = 1;
						flag[f[i][0]] = true;
						flag[f[i][1]] = true;
						flag[f[i][2]] = true;
						flag[f[i][3]] = true;

						if (!flag[b[0]])
							v *= max(0, C - b[0]);
						v %= pmod;
						for (p = 0; p < b[0]; ++p) {
							if (!flag[p])
								break;
						}
						if (p < b[0])
							continue;
						flag[b[0]] = true;

						if (!flag[b[1]])
							v *= max(0, C - b[1]);
						v %= pmod;
						for (p = 0; p < b[1]; ++p) {
							if (!flag[p])
								break;
						}
						if (p < b[1])
							continue;
						flag[b[1]] = true;

						if (!flag[b[2]])
							v *= max(0, C - b[2]);
						v %= pmod;
						for (p = 0; p < b[2]; ++p) {
							if (!flag[p])
								break;
						}
						if (p < b[2])
							continue;
						flag[b[2]] = true;

						if (!flag[b[3]])
							v *= max(0, C - b[3]);
						v %= pmod;
						for (p = 0; p < b[3]; ++p) {
							if (!flag[p])
								break;
						}
						if (p < b[3])
							continue;
						flag[b[3]] = true;

						int add = 0;
						if (b[0] == f[i][0])
							add++;
						if (b[1] == f[i][1])
							add++;
						if (b[2] == f[i][2])
							add++;
						if (b[3] == f[i][3])
							add++;
						if (b[0] == b[1])
							add++;
						if (b[1] == b[3])
							add++;
						if (b[3] == b[2])
							add++;
						if (b[2] == b[0])
							add++;
						int typ;
						if (b[0] == b[1] && b[1] == b[2] && b[2] == b[3])
							typ = 5;
						else if (b[0] == b[1] && b[1] == b[3])
							typ = 6;
						else if (b[1] == b[3] && b[3] == b[2])
							typ = 6;
						else if (b[3] == b[2] && b[2] == b[0])
							typ = 6;
						else if (b[2] == b[0] && b[0] == b[1])
							typ = 6;
						else if (b[0] == b[1] && b[2] == b[3])
							typ = 2;
						else if (b[0] == b[2] && b[1] == b[3])
							typ = 2;
						else if (b[0] == b[3] && b[1] == b[2])
							typ = 1;
						else if (b[0] == b[1] || b[1] == b[3] || b[3] == b[2]
								|| b[2] == b[0])
							typ = 4;
						else if (b[0] == b[3] || b[1] == b[2])
							typ = 3;
						else
							typ = 0;
						for (k = 0; k + add <= K; ++k) {
							a[id[i][k]][id[typ][k + add]] += v;
							a[id[i][k]][id[typ][k + add]] %= pmod;
						}
					}
				}
			}
		}
	}
	memset(t, 0, sizeof(t));
	for (i = 0; i < ed; ++i) {
		a[i][ed] = 1;
		t[i][i] = 1;
	}
	t[ed][ed] = 1;
	a[ed][ed] = 1;
	ed++;
	while (H) {
		if (H & 1)
			mul(t, a);
		mul(a, a);
		H >>= 1;
	}
	long long ans = 0;
	/*
	 0.  1.  2.  2.  3.  3.  4.  4.  4.  4.  5.  6.
	 ab  ab  ab  aa  ab  ab  ab  ab  aa  ac  aa  aa
	 cd  ba  ab  bb  ca  bc  ac  cb  cb  bb  aa  ab
	 */
	//0
	if (C >= 4)
		ans += t[id[0][0]][ed - 1] * C * (C - 1) % pmod * (C - 2) * (C - 3)
				% pmod;
	//1
	if (C >= 2)
		ans += t[id[1][0]][ed - 1] * C * (C - 1) % pmod;
	//2
	if (C >= 2)
		if (K >= 2)
			ans += t[id[2][2]][ed - 1] * C * (C - 1) * 2 % pmod;
	//3
	if (C >= 3)
		ans += t[id[3][0]][ed - 1] * C * (C - 1) % pmod * (C - 2) * 2 % pmod;
	//4
	if (C >= 3)
		if (K >= 1)
			ans += t[id[4][1]][ed - 1] * C * (C - 1) % pmod * (C - 2) * 4
					% pmod;
	//5
	if (C >= 1)
		if (K >= 4)
			ans += t[id[5][4]][ed - 1] * C;
	//6
	if (C >= 2)
		if (K >= 2)
			ans += t[id[6][2]][ed - 1] * C * (C - 1) * 4 % pmod;
	ans %= pmod;
	return ans;
}


### 什么是供应商关系管理系统(SRM) 供应商关系管理系统(Supplier Relationship Management, SRM)是一种旨在帮助企业优化其与供应商之间合作关系的信息技术工具。它通过集成化的流程管理和数据分析能力,提升企业在采购、供应链协作以及资源分配方面的效率和透明度[^1]。 #### SRM 的产生背景 随着全球化进程加快,企业面临的市场竞争日益激烈,传统的采购管理模式已无法满足现代商业环境的需求。为了降低采购成本并提高供应链灵活性,SRM 应运而生。该系统的引入不仅能够改善企业内部运作机制,还促进了外部合作伙伴之间的高效沟通与合作。 #### SRM 的核心功能 SRM 系统通常具备以下几类主要功能: - **供应商全生命周期管理**:覆盖从潜在供应商评估到正式签约再到绩效考核的全过程。 - **采购流程自动化**:支持在线询价、报价处理、合同签订等功能,减少人工干预带来的错误风险。 - **数据共享与协同工作**:与其他业务系统(如ERP、WMS等)无缝对接,实现跨部门甚至跨国界的数据交换和服务调用[^2]。 - **分析决策支持**:利用大数据技术和人工智能算法挖掘隐藏价值,辅助管理层制定科学合理的策略方向[^3]。 #### SRM 对企业的战略意义 实施有效的SRM方案可以帮助公司获得多方面收益,包括但不限于削减开支、缩短交货周期、改进产品质量等方面的表现;同时也有助于构建长期稳定可信赖的合作网络,在不确定因素增多的情况下保持竞争优势地位[^4]。 ```python class SupplierRelationshipManagementSystem: def __init__(self): self.modules = ["Supplier Lifecycle", "Procurement Automation", "Data Collaboration"] def manage_suppliers(self): print("Managing suppliers through lifecycle stages.") def automate_procurements(self): print("Automating procurement processes with digital tools.") def collaborate_data(self): print("Facilitating data collaboration across systems.") ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值