CodeForces 471C MUH and House of Cards
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make:
- The house consists of some non-zero number of floors.
- Each floor consists of a non-zero number of rooms and the ceiling. A room is two cards that are leaned towards each other. The rooms are made in a row, each two adjoining rooms share a ceiling made by another card.
- Each floor besides for the lowest one should contain less rooms than the floor below.
Please note that the house may end by the floor with more than one room, and in this case they also must be covered by the ceiling. Also, the number of rooms on the adjoining floors doesn't have to differ by one, the difference may be more.
While bears are practicing to put cards, Horace tries to figure out how many floors their house should consist of. The height of the house is the number of floors in it. It is possible that you can make a lot of different houses of different heights out of n cards. It seems that the elephant cannot solve this problem and he asks you to count the number of the distinct heights of the houses that they can make usingexactlyn cards.
Input
The single line contains integer n (1 ≤ n ≤ 1012) — the number of cards.
Output
Print the number of distinct heights that the houses made of exactly n cards can have.
Sample Input
13
1
6
0
Hint
In the first sample you can build only these two houses (remember, you must use all the cards):
Thus, 13 cards are enough only for two floor houses, so the answer is 1.
The six cards in the second sample are not enough to build any house.
#include <stdio.h> int main()
{
long long n,num;
long long i,j;
while(scanf("%I64d",&n)!=EOF)
{
num=;
for(i=;;i++)
{
long long x=(*(i+)*(i+))/+(i*(i+))/,y;
//printf("%I64d\n",x);
if(n>=x)
y=n-x;
else
break;
if(y%==)
num++;
}
printf("%I64d\n",num);
}
return ;
}
CodeForces 471C MUH and House of Cards的更多相关文章
- codeforces 471C.MUH and House of Cards 解题报告
题目链接:http://codeforces.com/problemset/problem/471/C 题目意思:有 n 张卡,问能做成多少种不同楼层(floor)的 house,注意这 n 张卡都要 ...
- [CF 471C] MUH and House of Cards
C. MUH and House of Cards Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elep ...
- codeforces 471B. MUH and Important Things 解题报告
题目链接:http://codeforces.com/problemset/problem/471/B 题目意思:有 n 个 tasks,编号依次为 1 - n,每个 task 都有一定的难度值来评估 ...
- Codeforces Round #364 (Div. 2)->A. Cards
A. Cards time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- codeforces 680A A. Bear and Five Cards(水题)
题目链接: A. Bear and Five Cards //#include <bits/stdc++.h> #include <vector> #include <i ...
- Codeforces Round #460 D. Karen and Cards
Description Karen just got home from the supermarket, and is getting ready to go to sleep. After tak ...
- [CodeForces 471A] MUH and Sticks
题目链接:http://codeforces.com/problemset/problem/471/A 题目数据规模1 - 9,可以用一个数组进行计数,减掉出现四次的数,看看还有几个是非零数,有一个就 ...
- codeforces 235 div2 A. Vanya and Cards
Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer ...
- CodeForces 471D MUH and Cube Walls -KMP
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of ...
随机推荐
- PAT乙级 1011. A+B和C (15)
1011. A+B和C (15) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 HOU, Qiming 给定区间[-231, 231 ...
- 【py网页】urlopen的补充,完美
urllib 是 python 自带的一个抓取网页信息一个接口,他最主要的方法是 urlopen(),是基于 python 的 open() 方法的.下面是主要说明: 1 urllib.urlopen ...
- 给图像添加logo
#include <opencv2\opencv.hpp>#include"ProcessPixels.h"using namespace cv;using names ...
- DOM4J解析xml案例
- STM32的寄存器控制SDA_IN()/SDA_OUT()
#define SDA_IN() {GPIOA->CRL&=0X0FFFFFFF;GPIOA->CRL|=(u32)8<<28;}#define SDA_OUT() ...
- zabbix源码安装
Zabbix通过C/S模式采集数据,通过B/S模式在web端展示和配置. 被监控端:主机通过安装agent方式采集数据,网络设备通过SNMP方式采集数据 Server端:通过收集SNMP和agent发 ...
- PBOC APDU命令解析【转】
转自:http://blog.csdn.net/zuokong/article/details/49335257 版权声明:本文为博主原创文章,未经博主允许不得转载. 应用层发出的命令报文和卡片回送到 ...
- vlc分析
vlc的主界面对应的代码在vlc-2.2.1\modules\gui\qt4\main_interface.cpp.在相同目录下的qt4.cpp的module模块open函数里边new出实例: /* ...
- JavaScript DOM 编程艺术(第2版)读书笔记 (8)
<!--这章的内容略奇怪啊!可能是因为我之前没有接触过这些知识点,等以后用到的时候再回来翻阅吧,现在先简要介绍一下 js权限已通过,博客园好快的效率啊,谢谢O(∩_∩)O --> 缩略语 ...
- JavaScript DOM 编程艺术(第2版)读书笔记(1)
JavaScript 简史 JavaScript 是Netscape公司与Sun公司合作开发的.在 JavaScript 1.0发布时,Netscape Navigator主宰着浏览器市场.微软在推出 ...