题解 | #尼科彻斯定理#

尼科彻斯定理

http://www.nowcoder.com/practice/dbace3a5b3c4480e86ee3277f3fe1e85

C++的^是异或我老是搞成幂符号,啊啊啊我去

#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int x;
    while(cin>>x){
        int start,end;
        string out;
        start = pow(x-1,2)+x;
        end = pow(x,2)+x-1;
        for(int i =start;i<=end;i+=2){
            out+=to_string(i)+'+';
        }
        if(!out.empty())out = out.erase(out.size()-1);
        cout<<out<<endl;
        
    }
}

全部评论

相关推荐

中电45所 测试开发岗 可以解决北京户口,提供员工宿舍,早 8 晚 5(不过一般会加班到7-8点,周六一般也会去,面试官说的) 硕士
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务