题解 | #序列和#

序列和

https://www.nowcoder.com/practice/46eb436eb6564a62b9f972160e1699c9

#include<iostream>

using namespace std;
int main(){
    
    int N=0,L=0;
    bool have_out=0;
    while(cin>>N>>L){
        have_out=0;
        while(L<=100&&N>=(L*(L-1)/2)){      
            if((2*N-L*L+L)%(2*L)==0){
                int n=(2*N-L*L+L)/(2*L);
                for(int i=0;i<L;i++){
                    cout<<n+i;
                    if(i!=L-1){
                        cout<<' ';
                    }
                }
                cout<<endl;
                have_out=1;
                break;
            }
            L++;
        }
        
        if(have_out==0){
            cout<<"No"<<endl;
        }
    }
    return 0;
    
    
}

#网易雷火#
全部评论

相关推荐

这算盘打的
程序员小白条:都这样的,都是潜规则,你自己说可以实习一年就行了,实习可以随便跑路的
点赞 评论 收藏
分享
我是没经验的毕业生,这啥情况啊会不会是hr在刷kpi
JamesGosli...:字节boss属于是群发了,我都快入职字节了,其他部门还在和我boss打招呼
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务