Spoj-BOKAM143SOU Checking cubes.
Given a integer N. Find number of possible ways to represent N as a sum of at most five cubes.
Input
First line contains N.
1<=N<=125000.
Output
Output the result
Example
Input:
64 Output:
2 这种题目。。直接暴力吧
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void write(LL a)
{
if (a<){printf("-");a=-a;}
if (a>=)write(a/);
putchar(a%+'');
}
inline void writeln(LL a){write(a);printf("\n");}
int n,m,tot,ans;
int p[];
int mrk[];
int main()
{
scanf("%d",&n);
for (int i=;i<=;i++)p[i]=i*i*i,mrk[p[i]]=i;
for (int i=;i<=;i++)
{
if (tot+p[i]>n)break;
tot+=p[i];
for (int j=i;j<=;j++)
{
if(tot+p[j]>n)break;
tot+=p[j];
for (int k=j;k<=;k++)
{
if (tot+p[k]>n)break;
tot+=p[k];
for (int l=k;l<=;l++)
{
if (tot+p[l]>n)break;
tot+=p[l];
for (int m=l;m<=;m++)
if (tot+p[m]==n)ans++;
tot-=p[l];
}
tot-=p[k];
}
tot-=p[j];
}
tot-=p[i];
}
printf("%d\n",ans);
}
Spoj BOKAM143SOU
Spoj-BOKAM143SOU Checking cubes.的更多相关文章
- CentOS:ECDSA host key "ip地址" for has changed and you have requested strict checking(转)
原文地址:http://blog.csdn.net/ausboyue/article/details/52775281 Linux SSH命令错误:ECDSA host key "ip地址& ...
- BZOJ 2588: Spoj 10628. Count on a tree [树上主席树]
2588: Spoj 10628. Count on a tree Time Limit: 12 Sec Memory Limit: 128 MBSubmit: 5217 Solved: 1233 ...
- Sensitive directory/file Integrity Monitoring and Checking
catalogue . OSSEC . HashSentry: Host-Based IDS in Python . Afick . 检测流程 1. OSSEC OSSEC is an Open So ...
- SPOJ DQUERY D-query(主席树)
题目 Source http://www.spoj.com/problems/DQUERY/en/ Description Given a sequence of n numbers a1, a2, ...
- 水泡动画模拟(Marching Cubes)
Marching Cubes算法是三维离散数据场中提取等值面的经典算法,其主要应用于医学领域的可视化场景,例如CT扫描和MRI扫描的3D重建等. 算法主要的思想是在三维离散数据场中通过线性插值来逼近等 ...
- SPOJ GSS3 Can you answer these queries III[线段树]
SPOJ - GSS3 Can you answer these queries III Description You are given a sequence A of N (N <= 50 ...
- Codeforces525E Anya and Cubes(双向搜索)
题目 Source http://codeforces.com/contest/525/problem/E Description Anya loves to fold and stick. Toda ...
- 【填坑向】spoj COT/bzoj2588 Count on a tree
这题是学主席树的时候就想写的,,, 但是当时没写(懒) 现在来填坑 = =日常调半天lca(考虑以后背板) 主席树还是蛮好写的,但是代码出现重复,不太好,导致调试的时候心里没底(虽然事实证明主席树部分 ...
- 高并发下MySQL出现checking permissions
在某些数据访问层框架中,会使用show full tables from test like 'demo',来检查数据库的状态.当数据库中表的数量较少时,并没有出现严重的问题.但是当数据库中的表数量多 ...
随机推荐
- SQL server 数据库基础语句 查询语句
这一章要学习查询语句 我看car这一数据 我们就开始打上 select *from car 条件修改 update 表名 set 列名1=值1 where 列名2=值2 //当列名2=值2时 ...
- POJ 2955 Brackets (区间DP,常规)
题意: 给出一个字符串,其中仅仅含 “ ( ) [ ] ” 这4钟符号,问最长的合法符号序列有多长?(必须合法的配对,不能混搭) 思路: 区间DP的常规问题吧,还是枚举区间[i->j]再枚举其中 ...
- Solr笔记(2)_Schema.xml和solrconfig.xml分析
现在我们开始研究载入的数据部分(importing data) 在正式开始前,我们先介绍一个存储了大量音乐媒体的网站http://musicbrainz.org , 这里的数据都是免费的,一个大型开放 ...
- chrom浏览器-F2使用方法一
由于F12是前端开发人员的利器,所以我自己也在不断摸索中,查看一些博客和资料后,自己总结了一下来帮助自己理解和记忆,也希望能帮到有需要的小伙伴,嘿嘿! 首先介绍Chrome开发者工具中,调试时使用最多 ...
- shell脚本,通过传参求斐波那契数列如(0,1,1,2,3,5,8,13..........)
[root@localhost wyb]# cat fibo.sh #!/bin/bash #斐波那契数列 ,,,,,,, > file >> file count=$ for i ...
- iOS 设计模式
很赞的总结 iOS Design Patterns 中文版 IOS设计模式之一(MVC模式,单例模式) IOS设计模式之二(门面模式,装饰器模式) IOS设计模式之三(适配器模式,观察者模式) IOS ...
- passive event 解决方法
为了让页面滚动的效果如丝般顺滑,从 chrome56 开始,在 window.document 和 body 上注册的 touchstart 和 touchmove 事件处理函数,会默认为是 pass ...
- 洛谷 P2921 在农场万圣节
https://www.luogu.org/problemnew/show/P2921 开始感觉这题30行代码就可以搞定,还是太菜啦,还是乖乖地写了tarjan. 对图进行缩点,那么这个强联通分量中的 ...
- [LUOGU] 1717 钓鱼
题目描述 话说发源于小朋友精心设计的游戏被电脑组的童鞋们藐杀之后非常不爽,为了表示安慰和鼓励,VIP999决定请他吃一次"年年大丰收",为了表示诚意,他还决定亲自去钓鱼,但是,因为 ...
- C语言之extern、const、volatile
extern: extern修饰变量,声明该变量为外部文件的全局变量.若使用外部全局变量,必须用extern声明. extern修饰函数,声明该函数为外部函数.extern修饰的函数形参必须与原函数一 ...