Cod sursa(job #3206081)

Utilizator BlaugranasEnal Gemaledin Blaugranas Data 21 februarie 2024 17:02:22
Problema Progresie Scor 0
Compilator cpp-64 Status done
Runda Arhiva ICPC Marime 0.38 kb
#include<bits/stdc++.h>
using namespace std;
ifstream F("progresie.in");
ofstream G("progresie.out");
int t;
long long n,r,i,v,l,b,x,y,e,j;
bool o;
int main()
{
    for(F>>t;t--;)
        for(o=i=1,F>>n>>r;f;l+e>=x?G<<v<<'\n',o=0:++i)
            for(j=1,v=i*(i-1)+1,e=i-1;j<n&&(l=v+j*r,b=sqrt(l-1)+1,x=b*(b-1)+1,y=b*b,l<x?v+=x-l,e+=l-x:e=min(e,y-l),l+e>=x);++j);
    return 0;
}