Submission

Status:

P-P-PPP--P

Subtask/Task Score:

60/100

Score: 60

User: exoworldgd

Problemset: Weird Castle

Language: cpp

Time: 0.002 second

Submitted On: 2026-02-23 23:59:37

#pragma GCC optimize("O5,unroll-loops,inline,fast-math,omit-frame-pointer,tree-vectorize")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt,tune=native,fma,abm,mmx,sse")
#include <bits/stdc++.h>
#define int long long
#define exoworldgd cin.tie(0)->sync_with_stdio(0),cout.tie(0)
using namespace std;
int N,X,r1,r2,c1,c2;
signed main(void){
	exoworldgd;
	cin>>N>>X,r1=ceil(sqrt((long double)N)),r2=ceil(sqrt((long double)X)),c1=N-(r1-1)*(r1-1),c2=X-(r2-1)*(r2-1),cout<<max({llabs(c1-c2),llabs(r1-r2),llabs((r1-c1)-(r2-c2))});
}