首页 > 其他分享 >Codeforces-182E 题解

Codeforces-182E 题解

时间:2024-04-10 14:56:30浏览次数:18  
标签:Vasya boards fence 题解 Codeforces board th 182E type

Vasya has recently bought some land and decided to surround it with a wooden fence.

He went to a company called "Wooden board" that produces wooden boards for fences. Vasya read in the catalog of products that the company has at its disposal \(n\) different types of wood. The company uses the i-th type of wood to produce a board of this type that is a rectangular ai by bi block.

Vasya decided to order boards in this company and build a fence from them. It turned out that the storehouse of the company is so large that Vasya can order arbitrary number of boards of every type. Note that Vasya is allowed to turn the boards as he builds the fence. However, Vasya cannot turn square boards.

Vasya is required to construct a fence of length l, however, an arbitrary fence won't do. Vasya wants his fence to look beautiful. We'll say that a fence is beautiful if and only if the following two conditions are fulfilled:

there are no two successive boards of the same type
the first board of the fence has an arbitrary length, and the length of each subsequent board equals the width of the previous one
In other words, the fence is considered beautiful, if the type of the i-th board in the fence is different from the i - 1-th board's type; besides, the i-th board's length is equal to the i - 1-th board's width (for all i, starting from 2).

Now Vasya wonders, how many variants of arranging a fence for his land exist. Your task is to count the number of different beautiful fences of length l.

Two fences will be considered the same if the corresponding sequences of fence boards types and rotations are the same, otherwise the fences are different. Since the sought number can be large enough, you need to calculate the answer modulo 1000000007 (109 + 7).

标签:Vasya,boards,fence,题解,Codeforces,board,th,182E,type
From: https://www.cnblogs.com/binarydreamer/p/18126017

相关文章

  • 20240410每日一题题解
    20240410每日一题题解Problem一只小猴买了若干个桃子。第一天他刚好吃了这些桃子的一半,又贪嘴多吃了一个;接下来的每一天它都会吃剩余的桃子的一半外加一个。第\(n\)天早上起来一看,只剩下\(1\)个桃子了。请问小猴买了几个桃子?输入一个正整数\(n\),表示天数。输出小猴买了多......
  • 分享30个外贸常见的问题解答
    顶易四月海关众筹活动实时参与人数已达1835,剩余名额不多。33国海关数据仅需300,一年只卖一次,需要续费/新购请抓紧时间!1、客户:我不会再为这笔订单支付更多的费用,也不接受其他条款。外贸人:下周交货期如果你能找得到其他供货商的话,我们很乐意把生产了一半的货送到另外一个供货......
  • 启动应用程序出现ieui.dll找不到问题解决
    其实很多用户玩单机游戏或者安装软件的时候就出现过这种问题,如果是新手第一时间会认为是软件或游戏出错了,其实并不是这样,其主要原因就是你电脑系统的该dll文件丢失了或没有安装一些系统软件平台所需要的动态链接库,这时你可以下载这个ieui.dll文件(挑选合适的版本文件)把它放入......
  • 启动应用程序出现inetcomm.dll找不到问题解决
    其实很多用户玩单机游戏或者安装软件的时候就出现过这种问题,如果是新手第一时间会认为是软件或游戏出错了,其实并不是这样,其主要原因就是你电脑系统的该dll文件丢失了或没有安装一些系统软件平台所需要的动态链接库,这时你可以下载这个inetcomm.dll文件(挑选合适的版本文件)把它......
  • el-table(V 2.15.14)在使用树结构表格并且设置align = 'center'后 树结构层级不明显问
    开发中遇到的小问题:如图所示三个层级区分并不明显,用户体验差解决方案:自定义CSS:首先取消此列的align="center"然后插入以下代码(此CSS为更改图示第二列的样式如果是其它列请自己获取样式名称)//标题居中::v-deepth.el-table_1_column_2.is-leaf.el-table__cell{t......
  • [ABC348] Atcoder ABC 248 A~G 题解
    [ABC348]AtcoderABC248A~G题解A模拟B模拟,不卡精度。C模拟D注意,药不可以拿着,只可以在那个格子吃掉。这就意味着,我们无论何时到达某个点,到达的点的集合都是固定的。所以对于每个药店跑BFS,然后看起点到终点是否连通即可。intn,m,k,ad[N][N],f[N][N],in[N][N],......
  • 20240409每日一题题解
    20240409每日一题题解Problem给你一个数组nums和一个值val,你需要原地移除所有数值等于val的元素,并返回移除后数组的新长度。不要使用额外的数组空间,你必须仅使用O(1)额外空间并原地修改输入数组。元素的顺序可以改变。你不需要考虑数组中超出新长度后面的元素。So......
  • 问题解决 usr/include/c++/11/bits/list.tcc:344:24: error: no match for ‘operator
    1.问题解决usr/include/c++/11/bits/list.tcc:344:24:error:nomatchfor‘operator==’错误解释:这个编译错误表明编译器在尝试使用==操作符比较两个对象时找不到匹配的操作符函数。在C++中,如果你尝试比较两个自定义类型的对象,且没有为这些对象定义==操作符,编译器将无法进......
  • 【题解 | 二叉树】给定二叉树的后序遍历和中序遍历,求层序遍历结果
    树的遍历给定一棵二叉树的后序遍历和中序遍历,请你输出其层序遍历的序列。这里假设键值都是互不相等的正整数。输入格式:输入第一行给出一个正整数N(≤......
  • Codeforces Round 938 (Div. 3)题解(A-E)
    A.YogurtSale题意:输入一份酸奶a元,两份b元,求买n份酸奶最少要多少钱。#include<iostream>#include<string>#include<cstring>#include<algorithm>usingnamespacestd;typedeflonglongll;constintN=1e6+7;voidsolve(){ intn,a,b;cin>>n>>......