codeforces1469D Ceil Divisions (construction questions, law questions)

Portal
problem solution: in fact, it is a problem constructed by discovering the rules, and the problem needs n + 5 n+5n+The 5- step construction is completed, then there must be many operations in theiiThe number of i divided by thei + 1 i+1i+1 number, you can find that if a large number wants to drop, the least is2 22 step operation, in fact, it is an extra1 11 step operation, then up to5 5 moreThere are 5 numbers. These numbers are bound to be related. Lenovo can also think of operations under the radical sign. You can see2 e 5 2e52 e 5 can be changed to2 2 withup to three or four root signs2 out.

int n;
vector<pair<int,int> >ans;
int main(){
    
    
    #ifdef io
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    rush(){
    
    
        cin>>n;
        ans.clear();
        while(n!=2){
    
    
            int next=ceil(sqrt(1.0*n));
            rep(i,max(3,next+1),n-1)ans.push_back({
    
    i,i+1});
            ans.push_back({
    
    n,next});
            ans.push_back({
    
    n,ceil(n*1.0/next)});
            if(next==2)break;
            else n=next;
        }
        int len=ans.size();
        pf(len);
        rep(i,0,ans.size()-1)pf2(ans[i].fi,ans[i].se);
    }
    return 0;
}

Guess you like

Origin blog.csdn.net/zhouzi2018/article/details/112193359