zoukankan      html  css  js  c++  java
  • Problem B

    题意:

    你可以用图示的方法建造金字塔,但是每一次都要建最大的金字塔,问最后能建几个金字塔。

    思路:

    我们可以发现对于每一个金字塔都是两边增加了两天边,然后中间行数− 1 -1−1个三角形,所以就可以求出每一个金字塔的边数
    (∑ _{i = 0} ^k i ∗ 3 + 2),然后从最大的金字塔开始遍历,如果可以建造的话,就一直减去对应的边数,然后重复此过程

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll _, n, m, a[1000];
    int main() {
    	//freopen("in.txt", "r", stdin);
    	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    	cin >> _; while (_--) {
    		cin >> n; m = 0;
    		while (n > 1) {
    			ll k = 2;
    			m++;
    			while (n >= k)n -= k, k += 3;
    		}
    		cout << m << endl;
    	}
    }
    

    The desire of his soul is the prophecy of his fate
    你灵魂的欲望,是你命运的先知。

  • 相关阅读:
    Kubernetes之Replica Set
    Kubernetes之Replication Controller
    Kubernetes之Deployment
    golang channel select
    golang slice
    epoll的由来
    ceph crush 之 crush_do_rule
    libevent
    P2P资料
    混沌理论学习笔记
  • 原文地址:https://www.cnblogs.com/RioTian/p/13658417.html
Copyright © 2011-2022 走看看