【CodeForces - 471C】MUH and House of Cards (思维,找规律)

题干:

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:

  1. The house consists of some non-zero number of floors.
  2. 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.
  3. 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 using exactly n 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.

Examples

Input

13

Output

1

Input

6

Output

0

Note

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.

题目大意:

   现在有n个卡片,问能叠成多少种高度的房子。(叠法按照题意和图片就看出来了)

解题报告:

    直接枚举,因为可以发现推出来的公式中是平方级别的,所以复杂度就是1e6左右,可以直接暴力。推公式是这么推的:先按照最少的方式看看可不可以叠出当前枚举的层数,然后再看剩下的卡片数是否是3的倍数,如果是3的倍数那就直接都加在最下面一层就ok了,否则就是这一层做不到。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 2e5 + 5;
ll n;
int main() 
{cin >> n;ll ans = 0;for (ll i = 1;; i++) {ll tmp = (i+1)*i/2 * 2;//房子 tmp += (i-1)*i/2;//天花板 if (tmp>n) break;if ((n-tmp)%3 == 0) ans++;}printf("%d\n",ans);return 0;
}

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/440935.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

哪个读书app可以导入txt_QQ阅读iphone版怎么导入电子书 三种手机QQ阅读器导入本地图书图文教程...

QQ阅读iphone版是一款比较方便的移动终端阅读软件&#xff0c;除了从电子书城下载或者购买电子书外&#xff0c;我们也可以把自己电脑中的电子书上传到QQ阅读软件中&#xff0c;不过果粉们都知道苹果手机没有文件管理器&#xff0c;无法使用qq阅读直接点击查看本地小说&#xf…

【CodeForces - 471B】MUH and Important Things (模拟,细节)

题干&#xff1a; Its time polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got down to business. In total, there are ntasks for the day and each animal should do each of these tasks. For each task, t…

大一计算机绩点3算什么水平,绩点只有3?我可以解释一下

放张图文无关压压惊最近开始申请学业奖学金了&#xff0c;大家开始计算自己的绩点&#xff0c;我也算了一下自己的成绩&#xff0c;结果是比3多一点点(如果没有算错的话)。我觉得这是一个比较合适的数字&#xff0c;没有比3小已经很满足了&#xff0c;毕竟学的并不好&#xff0…

不能用了 重装系统git_怎么用光盘重装系统?

身边没有U盘&#xff0c;电脑无法进入操作系统&#xff0c;只有一个系统光盘如何给电脑重装系统呢&#xff1f;受条件限制不能通过小白在线安装和U盘重装&#xff0c;今天教大家怎么用光盘重装系统吧。光盘重装系统准备工作1、保证电脑带有光驱功能&#xff0c;并且光驱处于正常…

【CodeForces - 472A】Design Tutorial: Learn from Math (tricks,思维,数论,打表)

题干&#xff1a; One way to create a task is to learn from math. You can generate some random math statement or modify some theorems to get something new and build a new task from that. For example, there is a statement called the "Goldbachs conject…

浙江经济职业技术学院计算机排名,浙江经济职业技术学院排名第几

关于浙江经济职业技术学院排名的问题考生问&#xff1a; 关于浙江经济职业技术学院的排名&#xff0c;我想抛给小编姐姐几个问题哦。一、浙江经济职业技术学院今年排名第几&#xff1f;对&#xff0c;指的是全国千余所专科院校当中的排名哦&#xff1b;二、浙江经济职业技术学院…

webform计算某几列结果_WebForm获取checkbox选中的值(几个简单的示例)

PS&#xff1a;最近在做权限管理这个模块&#xff0c;发现用checkbox的地方挺多的&#xff0c;于是写了个简单的例子&#xff0c;以供以后学习和使用。1.前端页面&#xff1a;张三李四王五赵六孙琦猪八2.后台方法&#xff1a;#region 获取从前端页面回传过来的 CheckBox 的值 v…

东明县计算机学校,东明县职业中等专业学校2021年招生信息

一、2021年东明县职业中等专业学校招生计划(一) 职教高考提前批招生计划学校代码专业名称招收人数学制学费备注说明863化学工艺40三年免学费从2022年起&#xff0c;山东省开始实施“职教高考”制度&#xff0c;采 取“文化素质职业技能”考试招生办法&#xff0c;职教高考的 本…

python去除图像光照不均匀_低光照环境下图像增强相关

Low-Light Image Enhancement via a Deep Hybrid Network [TIP2019]Underexposed Photo Enhancement using Deep Illumination Estimation[CVPR2019]---------Low-Light Image Enhancement via a Deep Hybrid Network [TIP2019]作者提出一个混合的网络来同时学习内容&#xff0…

【CodeForces - 523C】Name Quest (模拟)

题干&#xff1a; A Martian boy is named s — he has got this name quite recently from his parents for his coming of age birthday. Now he enjoys looking for his name everywhere. If he sees that he can obtain his name from some string by removing zero or mo…

w10计算机无法打印,老司机解答win10系统电脑无法打印的详细技巧

大家在使用电脑工作的时候会遇到win10系统电脑无法打印的问题&#xff0c;于是就有一些朋友到本站咨询win10系统电脑无法打印问题的解决步骤。解决win10系统电脑无法打印的问题非常简单&#xff0c;只需要你依照1、请确保打印机已打开并连接到你的电脑。 2、如果仍然无法工作&…

vb外部调用autocad_AutoCAD教程之图块的各种相关操作和概念

制图过程中&#xff0c;有时常需要插入某些特殊符号供图形中使用&#xff0c;此时就需要运用到图块及图块属性功能。利用图块与属性功能绘图&#xff0c;可以有效地提高作图效率与绘图质量。也是绘制复杂图形的重要组成部分。一、图块的特点图块是一组图形实体的总称&#xff0…

【CodeForces - 520C】DNA Alignment (快速幂,思维)

题干&#xff1a; Vasya became interested in bioinformatics. Hes going to write an article about similar cyclic DNA sequences, so he invented a new method for determining the similarity of cyclic sequences. Lets assume that strings s and t have the same l…

华北电力大学计算机考研大纲,2015年华北电力大学(保定)085211计算机技术考研大纲...

《529数据库原理及应用》一、考试内容范围&#xff1a;1.绪论1)数据管理技术的发展历史2)数据库管理系统的概念和功能3)数据库系统的特点4)数据库的三级模式结构、两级映像功能和数据独立性5)数据模型的组成要素和典型的数据模型6)概念模型的基本概念和概念模型的常用表示方法(…

echart 动画 饼图_echarts构建关系图,节点可收缩和展开,可添加点击事件

echarts下载及使用ECharts&#xff0c;一个使用 JavaScript 实现的开源可视化库&#xff0c;可以流畅的运行在 PC 和移动设备上&#xff0c;兼容当前绝大部分浏览器&#xff08;IE8/9/10/11&#xff0c;Chrome&#xff0c;Firefox&#xff0c;Safari等&#xff09;&#xff0c;…

【牛客 - 317C】小a与星际探索(背包dp 或 线性基)

题干&#xff1a; 小a正在玩一款星际探索游戏&#xff0c;小a需要驾驶着飞船从11号星球出发前往nn号星球。其中每个星球有一个能量指数pp。星球ii能到达星球jj当且仅当pi>pjpi>pj。 同时小a的飞船还有一个耐久度tt&#xff0c;初始时为11号点的能量指数&#xff0c;若小…

计算机及数控编程仿真软件exsl-win7,数控编程实验.doc

文档介绍&#xff1a;现代制造技术综合实验中心数控铣编程与仿真实验指导书1.实验目的:(1)通过上机实验巩固课堂所讲述的数控铣指令,掌握数控铣手工编程方法。(2)掌握EXSL-WIN7软件的编程及仿真等主要功能。2.实验设备或软件:计算机及数控编程仿真软件EXSL-WIN7。3.实验原理:根…

三菱socket通信实例_三菱自动化产品相关知识整理汇总

先从应用最广泛的PLC产品来说下&#xff1a;小型机&#xff1a;FX3S、FX3G、FX3U、FX5U 中型机&#xff1a;L系列大型机&#xff1a;Q系列、R系列Q是比较老的产品&#xff0c;也是现在大型机里面应用比较普遍的产品&#xff0c;在Q之后开发出性价比比较高的产品L系列和性能更高…

【牛客 - 317B】小a与204(贪心,构造,水题)

题干&#xff1a; 小a非常喜欢204204这个数字&#xff0c;因为′a′′k′204′a′′k′204。 现在他有一个长度为nn的序列&#xff0c;其中只含有2,0,42,0,4这三种数字 设aiai为序列中第ii个数&#xff0c;你需要重新排列这个数列&#xff0c;使得∑ni1(ai−ai−1)2∑i1n(ai−…

英语人机考试计算机算分吗,英语人机对话考试技巧

1英语 人机对话考试技巧目前要在英语口语人机对话中获得好的成绩&#xff0c;除了了解测试的特点之外&#xff0c;还需掌握一定的技巧、这对提高英语口语人机对话成绩将起到事半功倍的作用。接下来小编告诉你英语人机对话考试技巧。调整心态&#xff0c;临场莫慌听力不同于其他…