Cod sursa(job #3310041)

Utilizator popescu_georgePopescu George popescu_george Data 11 septembrie 2025 14:50:14
Problema Progresie Scor 0
Compilator cpp-64 Status done
Runda Arhiva ICPC Marime 0.59 kb
#include<fstream>
#include<cmath>
using namespace std;
ifstream cin("progresie.in");
ofstream cout("progresie.out");
int main()
{
    short t;
    for(cin>>t;t--;) {
        short n;
        int r;
        cin>>n>>r;
        bool o=1;
        for(long long i=1;o;) {
            long long v=i*(i-1)+1,e=i-1,l=0,x=0;
            int j=1;
            for(;j<n;++j) {
                long long l=v+1LL*j*r,q=sqrt(l);
                if(1LL*q*q!=l&&1LL*(q+1)*(q+1)-q>l)
                    break;
            }
            j==n?cout<<v<<'\n',o=0:++i;
        }
    }
    return 0;
}