Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: porpeang

Problemset: มุมขวาบน

Language: cpp

Time: 0.002 second

Submitted On: 2026-10-06 19:03:06

#include <bits/stdc++.h>
using namespace std;

int main(){
    long long a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,k=0;
    cin>>a;
    vector<int>vec;
    if (a < 5) {
        cout << 1 << "\n";
        return 0;
    }
    for(long long i=1;i<100000;i++){
        b=((4*i*i)+(2*i)-1);
        if(b==a){
            cout<<"Cannot find top-right corner.";
            c=1;
            break;
            
        }
    }
    if(c!=1){
        for(long long j=1;j<100000;j++){
            e=((4*j*j)+(2*j));
            d=((4*j*j)+(2*j)+1);

            f=((4*(j+1)*(j+1))+(2*(j+1)));
            g=((4*(j+1)*(j+1))+(2*(j+1))+1);
            
            if(a==e){
                cout<<e;
                break;
            }
            if(a==d){
                cout<<d;
                break;
            }
            if(a==f){
                cout<<f;
                break;
            }
            if(a==g){
                cout<<g;
                break;
            }
            if(a!=f && a!=g && a!=e && a!=d && a>d && a<f){
                cout<<d;
                break;
            }
        }
    }
    
    
    
    
    
}