砖块上的数字最终都可以看作是最后一行的线性组合,独立变元最多9个。

这类题的一般做法,线性组合都可以列出方程然后高斯消元。

对于这道题,只要确定最后一行剩下的4个变量就好了,对于最后一行的j位置,它对上面位置某个数字的和贡献次数

等于它到那个位置路径的方案数,可以发现就是杨辉三角。倒数第二行的数已经足够确定剩下的变量,x到对应位置y的方案是2。

x = (y - xleft - xright)/2.

/*********************************************************
* --------------Crispr--------------- *
* author AbyssalFish *
**********************************************************/
#include<bits/stdc++.h>
using namespace std; typedef long long ll; int b[][]; //#define LOCAL
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
int T, i, j; scanf("%d",&T);
while(T--){
for(i = ; i--;) scanf("%*d");
for(i = ; i < ; i += ) scanf("%d",b[]+i);
for(i = ; i < ; i += ) scanf("%d",b[]+i);
for(i = ; i < ; i += ){
b[][i] = (b[][i-] - b[][i-] - b[][i+])>>;
}
for(i = ; i--;){
for(j = ; j <= i; j++){
b[i][j] = b[i+][j] + b[i+][j+];
}
}
for(i = ; i < ; i++){
for(j = ; j <= i; j++){
printf("%d%c",b[i][j],j==i?'\n':' ');
}
}
}
return ;
}

UVA 11040 Add bricks in the wall(线性组合)的更多相关文章

  1. UVA 11040 Add bricks in the wall

    https://vjudge.net/problem/UVA-11040 找规律 #include<cstdio> using namespace std; ][]; int main() ...

  2. UVa 11040 Add bricks in the wall (水题递推)

    题意:给定一个金字塔,除了最后一行,每个数都等于支撑它的两个数的和,现在给奇数行的左数奇数位置,求整个金字塔. 析:很容易看出来,从下往上奇数行等于 a[i][j] = (a[i-2][j-1] - ...

  3. UVa 11040 (水题) Add bricks in the wall

    题意: 45块石头如图排列,每块石头上的数等于下面支撑它的两数之和,求其余未表示的数. 分析: 首先来计算最下面一行的数,A71 = A81 + A82 = A91 + 2A92 + A93,变形得到 ...

  4. Codeforces Round #676 (Div. 2) XORwice、Putting Bricks in the Wall、Palindromifier

    题目链接:XORwice 题意:给你两个数a.b.求一个数x,使得((a异或x)+(b异或x))这个值最小,输出最小那个x 题解: 输出(a|b)-(a&b)就行(猜了一手 代码: #incl ...

  5. 【NOIP合并果子】uva 10954 add all【贪心】——yhx

    Yup!! The problem name reects your task; just add a set of numbers. But you may feel yourselvesconde ...

  6. UVA 11076 Add Again 计算对答案的贡献+组合数学

    A pair of numbers has a unique LCM but a single number can be the LCM of more than one possiblepairs ...

  7. UVA 10954 Add All 哈夫曼编码

    题目链接: 题目 Add All Time Limit:3000MS Memory Limit:0KB 问题描述 Yup!! The problem name reflects your task; ...

  8. 【数论-数位统计】UVa 11076 - Add Again

    Add AgainInput: Standard Input Output: Standard Output Summation of sequence of integers is always a ...

  9. UVa 10954 Add All(优先队列)

    题意  求把全部数加起来的最小代价  a+b的代价为(a+b) 越先运算的数  要被加的次数越多  所以每次相加的两个数都应该是剩下序列中最小的数  然后结果要放到序列中  也就是优先队列了 #inc ...

随机推荐

  1. 在xcode中设置include和lib路径

    最近刚刚开始玩xcode,对着教程学编程时很少要动到项目设置,但昨天晚上想使用freetype验证上篇博文的问题,就需要设置include和lib路径了. 首先我下了freetype的源码,并在本地编 ...

  2. 树的直径 【bzoj3363】[Usaco2004 Feb]Cow Marathon 奶牛马拉松

    3363: [Usaco2004 Feb]Cow Marathon 奶牛马拉松 Description ​ 最近美国过度肥胖非常普遍,农夫约翰为了让他的奶牛多做运动,举办了奶牛马拉松.马拉 松路线要尽 ...

  3. 1、gitlab的理论知识

    2.1 svn与git对比 . svn git 分布式 不是 是 在线阅读 不支持 不仅支持,而且可以在线编辑 存储方式 按文件 按元数据 完整性 一般 优 离线工作 日志都没法看 完全没问题 分支 ...

  4. 小程序外部向组件内部传递externalClasses -- 传入样式wxss

    1.组件的JS添加配置 // 外部传入class类 externalClasses:['my-class'], 2.组件的wxml写法: 3.调用的页面 4.调用页面的wxss: 由于小程序的限制必须 ...

  5. POJ1021 2D-Nim

    题目来源:http://poj.org/problem?id=1021 题目大意: 有一种在棋盘上玩的游戏,每一步,一个玩家可以从棋盘上拿走连续行或列的棋子.谁拿到最后一颗棋子就胜利.如下图所示的棋盘 ...

  6. Codeforces Round #129 (Div. 2) B

    Description The Little Elephant loves sortings. He has an array a consisting of n integers. Let's nu ...

  7. spring retry注解

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  8. View转换为Bitmap及getDrawingCache

    View组件显示的内容可以通过cache机制保存为bitmap, 使用到的api有 void  setDrawingCacheEnabled(boolean flag),    Bitmap  get ...

  9. CentOS 7 iptables 开放8080端口

    # 安装iptables-services [root@localhost bin]# yum install iptables-services [root@localhost bin]# /bin ...

  10. java 核心技术 读后总结

    总结 1.少用八进制,以及二进制. 那么就是直接用16进制或10进制吗?额,想当年有这样搞过,后面就uuid了. 2.>>>用0填充高位>>用符号位填充高位<< ...