P14139

· · 题解

打表得此答案接近于 n^2+1 但有时候不是,于是想到求出答案和 n^2 的差,打表代码:

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n=0;
    while((++n)<=30){
        int ans=0;
        for(int i=1;i<=n;i++)ans+=i*i/n+floor(sqrt(i*n));
        cout<<n<<" "<<ans-n*n<<endl;
    }
    return 0;
}

得答案为 n^2+x ,其中 x=\max\{x|x^2|n\} , Pollard-Rho 因式分解即可