1 solutions

  • 0
    @ 2022-4-7 11:10:01

    模拟

    #include <bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define endl "\n"
    ll ans=0;
    int a[2000][2000]; 
    int dx[4]={-1,0,1,1};
    int dy[4]={1,1,-1,0};
    int main(){
    	int len=1;
    	a[1][1]=1;
    	int x=1,y=1;
    	int flag=0;
    	while(len<=800){
    		while(x+dx[flag]>=1&&y+dy[flag]>=1){
    			
    			a[x+dx[flag]][y+dy[flag]]=++len;
    			//cout<<x+dx[flag]<<" "<<y+dy[flag]<<" "<<len<<endl;
    			x+=dx[flag];
    			y+=dy[flag];
    		}
    		flag++;
    		x+=dx[flag];
    		y+=dy[flag];
    		a[x][y]=++len;
    		//cout<<x<<" "<<y<<" "<<len<<endl;
    		flag++;
    		flag%=4;
    	}
    	cout<<a[20][20]; 
    	return 0;
    }
    • 1

    Information

    ID
    6480
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    5
    Tags
    # Submissions
    80
    Accepted
    41
    Uploaded By