bzoj1643 / P2666 [Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪
[Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪
简单的dfs题
枚举前3个完全平方数,判断最后一个是不是完全平方数,统计合法方案数即可。
(zz选手竟把数据看成<=1e9)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n,ans;
void dfs(int t,int d){
if(d==){
int k=sqrt(t);
if(k*k==t) ++ans;
return ;
}
for(int i=;i*i<=t;++i)
dfs(t-i*i,d+);
}
int main(){
scanf("%d",&n);
dfs(n,);
printf("%d",ans);
return ;
}
bzoj1643 / P2666 [Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪的更多相关文章
- 1643: [Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪
1643: [Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 2 ...
- bzoj1643 [Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪
Description 农夫约翰已经从他的牧场中取得了数不清块数的正方形草皮,草皮的边长总是整数(有时农夫约翰割草皮的刀法不合适,甚至切出了边长为0的正方形草皮),他已经把草皮放在了一个奶牛贝茜已经知 ...
- 【枚举】bzoj1643 [Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪
显然<=n的平方数只有sqrt(n)个,三重循环枚举三块草坪,再减一下验证最后一块是不是平方数.O(n*sqrt(n)). #include<cstdio> #include< ...
- P1643: [Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪
呵呵呵呵呵,很水的DP,同时能够朴素枚举出来,这数据弱的 是 吃了尸米吧.. var n,i,j,k,l,ans:longint; begin readln(n); to trunc(sqrt(n)) ...
- 【BZOJ】1643: [Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪(dp)
http://www.lydsy.com/JudgeOnline/problem.php?id=1643 这题和完全背包十分相似, 但是不能用1维做........原因貌似是不能确定块数(还是有0的面 ...
- bzoj 1643: [Usaco2007 Oct]Bessie's Secret Pasture 贝茜的秘密草坪【枚举】
4维枚举平方小于10000的数,相加等于n则ans++ #include<iostream> #include<cstdio> using namespace std; con ...
- BZOJ 3407: [Usaco2009 Oct]Bessie's Weight Problem 贝茜的体重问题( dp )
01背包... ----------------------------------------------------------------------- #include<cstdio&g ...
- 3407: [Usaco2009 Oct]Bessie's Weight Problem 贝茜的体重问题
3407: [Usaco2009 Oct]Bessie's Weight Problem 贝茜的体重问题 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: ...
- bzoj3407 [Usaco2009 Oct]Bessie's Weight Problem 贝茜的体重问题
Description 贝茜像她的诸多姊妹一样,因为从约翰的草地吃了太多美味的草而长出了太多的赘肉.所以约翰将她置于一个及其严格的节食计划之中.她每天不能吃多过H(5≤日≤45000)公斤的干 ...
随机推荐
- Windows 10 下 PostgreSQL 生成 UUID(Guid)
最近在Windows 10 下安装了 PostgreSQL(postgresql-9.6.3-1-windows.exe),在学习过程中,发现PostgreSQL 支持UUID(Guid)类型,但是却 ...
- php intval的取值范围:与操作系统相关
php intval的取值范围:与操作系统相关,32位系统上为-2147483648到2147483647,64位系统上为-9223372036854775808到922337203685477580 ...
- SequenceFile实例操作
HDFS API提供了一种二进制文件支持,直接将<key,value>对序列化到文件中,该文件格式是不能直接查看的,可以通过hadoop dfs -text命令查看,后面跟上Sequen ...
- 2018牛客网暑期ACM多校训练营(第一场) J - Different Integers - [莫队算法]
题目链接:https://www.nowcoder.com/acm/contest/139/J 题目描述 Given a sequence of integers a1, a2, ..., an a ...
- Codeforces Round #435 (Div. 2)
A. Mahmoud and Ehab and the MEX 题目链接:http://codeforces.com/contest/862/problem/A 题目意思:现在一个数列中有n个数,每个 ...
- angularjs中的单选框绑定数据注意事项
这里说的是angularjs 1.x 在实现单选框时,我们完全可以用html自带的<input type="radio"/>,但是配合angularjs 中的双向绑定, ...
- Reading table information for completion of table and column names
mysql> use ad_detail_page;Reading table information for completion of table and column namesYou c ...
- ssh各种姿势---ssh-keygen 生成ssh公钥和私钥
利用ssh-keygen -t rsa可以生成ssh公钥和私钥,实现免输密码的ssh登陆 ssh-keygen -l -f /etc/ssh_host_rsa_key ssh-keygen ...
- 2018/03/09 每日一学PHP 之 require_once require include include_once 包含文件的区别
require_once require include include_once 方法的区别 对于包含文件来说,如果只是使用框架来说的话,应该会很少碰到,因为框架底层对于文件的引用等做了很好的封装, ...
- [python-opencv]超大图像二值化方法
*分块 *全局阈值 VS 局部阈值 import cv2 as cv import numpy as np def big_image_binary(image): print(image.shape ...