[BZOJ1643][Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪
1643: [Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪
Time Limit: 5 Sec Memory Limit: 64 MB Submit: 460 Solved: 386 [Submit][Status][Discuss]
Description
农夫约翰已经从他的牧场中取得了数不清块数的正方形草皮,草皮的边长总是整数(有时农夫约翰割草皮的刀法不合适,甚至切出了边长为0的正方形草皮),他已经把草皮放在了一个奶牛贝茜已经知道的地方。 贝茜总是希望把美味的草皮放到她的秘密庄园里,她决定从这些草皮中取出恰好4块搬到她的秘密庄园中,然后把它们分成1×1的小块,组成一个面积为N(1<=N<=10,000)个单位面积的部分。 贝茜对选出这样四块草皮的方法数很感兴趣,如果她得到了一个4个单位面积的部分,那么她可以有5中不同的方法选4块草皮:(1,1,1,1),(2,0,0,0),(0,2,0,0),(0,0,0,2).顺序是有效的:(4,3,2,1)和(1,2,3,4)是不同的方法。
Input
第一行:一个单独的整数N。
Output
单独的一行包含一个整数,表示贝茜选四块草皮的方案数。
Sample Input
Sample Output
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; char buf[10000000], *ptr = buf - 1; inline int readint(){int f = 1, n = 0;char ch = *++ptr;while(ch < '0' || ch > '9'){if(ch == '-') f = -1;ch = *++ptr;}while(ch <= '9' && ch >= '0'){n = (n << 1) + (n << 3) + ch - '0';ch = *++ptr;}return f * n; } const int maxn = 10000 + 10; int f[maxn][4] = {0}; int main(){fread(buf, sizeof(char), sizeof(buf), stdin);int N = readint();for(int k = 0; k * k <= N; k++) f[k * k][0] = 1;for(int i = 1; i < 4; i++)for(int j = 0; j <= N; j++)for(int k = 0; k * k <= j; k++)f[j][i] += f[j - k * k][i - 1];printf("%d\n", f[N][3]);return 0; }
转载于:https://www.cnblogs.com/ruoruoruo/p/7563050.html
[BZOJ1643][Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪相关推荐
- bzoj 1643: [Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪(DP)
1643: [Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪 Time Limit: 5 Sec Memory Limit: 64 MB Submit: ...
- bzoj 3407: [Usaco2009 Oct]Bessie's Weight Problem 贝茜的体重问题(DP)
3407: [Usaco2009 Oct]Bessie's Weight Problem 贝茜的体重问题 Time Limit: 3 Sec Memory Limit: 128 MB Submit: ...
- 【BZOJ3407】[Usaco2009 Oct]Bessie's Weight Problem 贝茜的体重问题【01背包】
[题目链接] ... /* Pigonometry */ #include <cstdio> #include <algorithm>using namespace std;c ...
- 洛谷——[USACO07OCT]Bessie‘s Secret Pasture S
P2666 [USACO07OCT]Bessie's Secret Pasture S 题目背景 背景就是描述,描述就是背景. 题目描述 Farmmer John最近收割了几乎无限多块牧草,将它们堆放 ...
- BZOJ-1644: [Usaco2007 Oct]Obstacle Course 障碍训练课(SPFA)
1644: [Usaco2007 Oct]Obstacle Course 障碍训练课 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 707 Solve ...
- bzoj 3393 bzoj 1644: [Usaco2007 Oct]Obstacle Course 障碍训练课(BFS)
1644: [Usaco2007 Oct]Obstacle Course 障碍训练课 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 680 Solve ...
- [Usaco2007 Oct] Super Paintball超级弹珠
Time Limit: 5 Sec Memory Limit: 64 MB Submit: 489 Solved: 384 [Submit][Status][Discuss] Descriptio ...
- BZOJ 1613: [Usaco2007 Jan]Running贝茜的晨练计划
题目 1613: [Usaco2007 Jan]Running贝茜的晨练计划 Time Limit: 5 Sec Memory Limit: 64 MB Description 奶牛们打算通过锻炼来 ...
- bzoj1613[Usaco2007 Jan]Running贝茜的晨练计划*
bzoj1613[Usaco2007 Jan]Running贝茜的晨练计划 题意: 贝茜进行N分钟的晨跑.在每分钟的开始,贝茜会选择下一分钟是用来跑步还是休息,如果贝茜选择在第i分钟内跑步,她可以在这 ...
最新文章
- Silverlight 3.0 不再包含 asp:silverlight 控件
- Python 解释器
- 用端口映射的办法使用矩池云隐藏的vnc功能
- 云计算数据中心网络性能测试
- arcgis api for js 下载(各版本最全面的地址)
- 平面设计论文要如何写?
- mysql blast2go_blast2go本地化教程
- 解决报错:SSL certificate problem: certificate has expired
- TR069服务器配置DHCP/IP/PING/Tracert/HTTP/PPPoE等仿真诊断模板及IPWAN和PPPoE WAN模板创建
- 网页设计(三)——JavaScript
- 游戏接入SDK系列之org.jf.util.ExceptionWithContext: Unsigned short value out of range
- 【回炉重造】带你搞懂什么是机器学习?
- git版本回退到某一次提交
- DM8:dexpdimp-逻辑导出--逻辑导入
- 分享107个竞聘述职PPT模板,总有一款适合您
- java导出数据为乱码_传参导出Excel表乱码问题解决方法
- 如何取消noarch.rpm包
- 什么是网站劫持,发现网站被劫持该怎么办?
- 如何确定今天是今年的第几周
- 戏说三种项目生命周期