zoukankan      html  css  js  c++  java
  • poj 2100 Graveyard Design

    Graveyard Design
    Time Limit: 10000MS   Memory Limit: 64000K
    Total Submissions: 7357   Accepted: 1816
    Case Time Limit: 2000MS

    Description

    King George has recently decided that he would like to have a new design for the royal graveyard. The graveyard must consist of several sections, each of which must be a square of graves. All sections must have different number of graves. 
    After a consultation with his astrologer, King George decided that the lengths of section sides must be a sequence of successive positive integer numbers. A section with side length s contains s2 graves. George has estimated the total number of graves that will be located on the graveyard and now wants to know all possible graveyard designs satisfying the condition. You were asked to find them.

    Input

    Input file contains n --- the number of graves to be located in the graveyard (1 <= n <= 1014 ).

    Output

    On the first line of the output file print k --- the number of possible graveyard designs. Next k lines must contain the descriptions of the graveyards. Each line must start with l --- the number of sections in the corresponding graveyard, followed by l integers --- the lengths of section sides (successive positive integer numbers). Output line's in descending order of l.

    Sample Input

    2030

    Sample Output

    2
    4 21 22 23 24
    3 25 26 27

    Source

    Northeastern Europe 2004, Northern Subregion
    /*
    * @Author: Lyucheng
    * @Date:   2017-08-02 16:43:37
    * @Last Modified by:   Lyucheng
    * @Last Modified time: 2017-08-02 21:22:15
    */
    /*
     题意:给你一个10^14的范围内的n,让你判断有多少连续子序列的平方和是n
    
     思路:尺取
    */
    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <set>
    #include <map>
    #include <string>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    
    #define LL long long
    #define INF 0xffffffff
    #define MAXN 10000001
    
    using namespace std;
    
    LL n;
    LL l,r;
    LL _min;
    LL pos;
    
    struct  Node{
        int l,r;
        Node(){}
        Node(int _l,int _r):l(_l),r(_r){}
    };
    vector<Node>v;
    
    void init(){
        v.clear();
        pos=0;
    }
    
    int main(){ 
        // freopen("in.txt", "r", stdin);
        // freopen("out.txt", "w", stdout);
        scanf("%I64d",&n);
        int cnt=((int)sqrt(n*1.0)) +1;
        init();
    
        l=1,r=1;
        _min=INF;
        while(r*r<=n&&l*l<=n){
            while(pos<n&&r*r<=n){
                pos+=r*r;
                r++; 
            }
            while(pos>n){
                pos-=l*l;
                l++;
            }
            if(pos==n){
                v.push_back(Node((int)l,(int)r-1));
                pos-=l*l;
                l++;  
            }
        }
        int tol=v.size();
        printf("%d
    ",tol);
        for(int i=0;i<tol;i++){
            printf("%d ",v[i].r-v[i].l+1);
            for(int j=v[i].l;j<=v[i].r;j++){
                printf(j==v[i].l?"%d":" %d",j);
            }
            printf("
    ");
        }
        return 0;
    }
  • 相关阅读:
    Visual Detection of Lintel-Occluded Doors from a Single Image
    Linux下快速构建Android编译环境
    How to Train YOLOv4 on a Custom Dataset
    yolo v4 darknet colab
    Deep Image Matting
    给 MSYS2 添加中科大的源
    msys2 mingw64 ffmpeg 搭建最新ffmpeg编译环境 可用 ffmpeg 4.1 及更新版本
    GB28181对接摄像机/NVR视频流
    video.js在iframe中如何解决无法自动播放问题
    LiveGBS-摄像机网页低延时无插件直播实现
  • 原文地址:https://www.cnblogs.com/wuwangchuxin0924/p/7276921.html
Copyright © 2011-2022 走看看