1. 程式人生 > >UVA1426-Add Bricks in The Wall

UVA1426-Add Bricks in The Wall

需要簡單的分析一下,上兩層的值可以通過隔一層來判斷。

#include<iostream>
#include<cstring>
#include<cstdio>
#include<math.h>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
using namespace std;
int a[11][11];
int main()
{
    int t;
    scanf("%d",&t);;
    while(t--)
    {
        for(int i=1;i<=9;i+=2)
            for(int j=1;j<=i;j+=2)
            scanf("%d",&a[i][j]);

        for(int i=9;i>=2;i--){
            if(i%2==1){
            for(int j=2;j<=i-1;j+=2)
            a[i][j]=(a[i-2][j-1]-a[i][j-1]-a[i][j+1])/2;
            }
            else{
            for(int j=1;j<=i;j++)
            a[i][j]=a[i+1][j]+a[i+1][j+1];
            }
        }

        for(int ii=1;ii<=9;ii++){
            for(int jj=1;jj<=ii;jj++)
            printf(jj!=ii?"%d ":"%d\n",a[ii][jj]);
        }
    }
    return 0;
}


相關推薦

UVA1426-Add Bricks in The Wall

需要簡單的分析一下,上兩層的值可以通過隔一層來判斷。 #include<iostream> #include<cstring> #include<cstdio> #

11.克服溝通障礙(How to break the bricks in conversation.)

1.What's this in English? 2.Can you speak slowly,I can't follow you.你能說慢點嗎?我跟不上你。 3.Pardon please.(請再說一次) 4.Sorry,I can't qu

Git add 報錯The file will have its original line endings in your working directory

報錯的圖片如下 解決的方式如下: 原因,查到了一個,不知道是不是 Git下處理“換行”(line ending)   core.autocrlf是git中負責處理line ending的變數,可以設定3個值:true,false,inout。 (1)設定為true【c

Xcode No account for team "". Add a new account in the Accounts preference pane or verify that your accounts have valid credenti

問題背景 Xcode報錯誤資訊:No account for team "QMP96B5DPW". Add a new account in the Accounts preference pane or verify that your accounts have valid credentials.

OSCache的原始碼編譯Cache.java 檔案報add(Class, T) in the type EventListenerList is not applicable for the arguments 錯誤的解決

下載了 OSCache的原始碼,需要新增一些功能,匯入Eclipse之後編譯,Cache.java 檔案報如下錯誤: Description Resource Path Location TypeThe method add(Class<T>, T) in the

iOS “[App] if we're in the real pre-commit handler we can't actually add any new fences due

我在執行程式的時候老是提示一堆”iOS “[App] if we’re in the real pre-commit handler we can’t actually add any new fences due”。這是編譯器內部的顯示,與 app 正常使用無

Package gtk+-3.0 was not found in the pkg-config search path

path 二進制 all 項目 有時 rpm fedora ack share 問題描述:   在fedora21系統上通過rpmbuild構建fcitx的二進制包時出現以上錯誤,經老程序員指點:“是相應的開發包沒有安裝” 解決辦法:   yum installl gtk3

HiHo1505:小Hi和小Ho的禮物(Meet-In-The-Middle + 組合數學)

整數 image namespace 多少 max using for 2種 100% 時間限制:10000ms 單點時限:1000ms 內存限制:256MB 描述 某人有N袋金幣,其中第i袋內金幣的數量是Ai。現在他決定選出2袋金幣送給小Hi,再選2袋金幣送給小H

TIME IN THE SUBWAY :GUESS NUM !

while switch guess number import java.util.Random;import java.util.Scanner;public class GuessNumber { public static void main(String[] args) {

[Codefoeces398B]Painting The Wall(概率DP)

cstring fine 傳送門 printf ring clu 綠色 type -i 題目大意:一個$n\times n$的棋盤,其中有$m$個格子已經被染色,執行一次染色操作(無論選擇的格子是否已被染色)消耗一個單位時間,染色時選中每個格子的概率均等,求使每一行、

ORA-23421: job number 225 is not a job in the job queue

conn uil bms delet ext roc erro declare dba_jobs   在對數據庫進行異機恢復之後,為了防止上面作業自動執行,擾亂正常業務系統,需要將測試庫上的作業和db_link進行刪除:但是使用sys用戶連接進去,刪除的時候報如下錯誤SQL

Namespace declaration statement has to be the very first statement in the script

ont 文件 space pac .net button php 解決 img php 中 Namespace declaration statement has to be the very first statement in the script 錯誤解決方

pycharm Zooming in the Editor

can span dialog eas open for .html rotate led https://www.jetbrains.com/help/pycharm/zooming-in-the-editor.html To enable changing font

Maven出現錯誤No plugin found for prefix 'jetty' in the current

jetty jpress Maven出現錯誤No plugin found for prefix ‘jetty‘ in the current project and in the plugin groups的問題解決只需在maven的setting.xml文件上加入如下節點:<pluginGr

解決Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 問題

== number keyword 解決辦法 class rac ref request 反斜杠 通過這裏的回答,我們可以知道: Tomcat在 7.0.73, 8.0.39, 8.5.7 版本後,添加了對於http頭的驗證。 具體來說,就是添加了些規則去限制HTTP頭

unity(使用了NGUI) 在Build時遇見DontSave but is included in the build

clu fonts 自動生成 tsa included image sources ext lag 錯誤提示: An asset is marked with HideFlags.DontSave but is included in the build:Asset: ‘L

Ubuntu 16.04 LTS 安裝libvips出現”Package vips was not found in the pkg-config search path”

arp dir exp export ron per gconf 部署 director 使用libvips來操作圖像,libvips的部署參考一個Node.js工程:https://github.com/lovell/sharp 在MAC下安裝很順利,到Linux環境下(

Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack.

dex parameter work put 嚴重 efi open post onerror 1、錯誤描寫敘述八月 14, 2015 4:22:45 下午 com.opensymphony.xwork2.util.logging.jdk.JdkLogger error

[Preact] Use State and Props in the Component Render Function

cnblogs use method nic imp ima rop component end Preact offers, in addition to the regular component API from React, the ability to acces

Gym 101246D Fire in the Country(dfs求SG函數)

tor 我們 style sizeof std clas mem class == http://codeforces.com/gym/101246/problem/D 題意: 給定一個無向有環圖,大火從1點開始,每個時間點與它相鄰的點也將會著火,現在有兩個人輪流操作機