update
This commit is contained in:
		
							parent
							
								
									19033d5af5
								
							
						
					
					
						commit
						37a87fdd9a
					
				
							
								
								
									
										44
									
								
								20240828/P2615/P2615.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								20240828/P2615/P2615.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,44 @@
 | 
				
			|||||||
 | 
					//AC
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					using namespace std;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const int MAX_N=39+5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main(){
 | 
				
			||||||
 | 
					    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int n;
 | 
				
			||||||
 | 
					    cin>>n;
 | 
				
			||||||
 | 
					    n=n/2*2+1;
 | 
				
			||||||
 | 
					    int a[MAX_N][MAX_N];
 | 
				
			||||||
 | 
					    for(int i=0;i<MAX_N;i++){
 | 
				
			||||||
 | 
					        for(int j=0;j<MAX_N;j++){
 | 
				
			||||||
 | 
					            a[i][j]=0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    const int pow_n = n*n;
 | 
				
			||||||
 | 
					    int x=1,y=n/2+1;
 | 
				
			||||||
 | 
					    a[x][y]=1;
 | 
				
			||||||
 | 
					    for(int i=2;i<=pow_n;i++){
 | 
				
			||||||
 | 
					        if(x==1&&y!=n){
 | 
				
			||||||
 | 
					            x=n,y+=1;
 | 
				
			||||||
 | 
					        }else if(y==n&&x!=1){
 | 
				
			||||||
 | 
					            x-=1,y=1;
 | 
				
			||||||
 | 
					        }else if(x==1&&y==n){
 | 
				
			||||||
 | 
					            x+=1;
 | 
				
			||||||
 | 
					        }else if(x!=1&&y!=n){
 | 
				
			||||||
 | 
					            if(a[x-1][y+1]==0){
 | 
				
			||||||
 | 
					                x-=1,y+=1;
 | 
				
			||||||
 | 
					            }else{
 | 
				
			||||||
 | 
					                x+=1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        a[x][y]=i;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    for(int i=1;i<=n;i++){
 | 
				
			||||||
 | 
					        for(int j=1;j<=n;j++){
 | 
				
			||||||
 | 
					            cout<<a[i][j]<<" ";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        cout<<endl;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -3,6 +3,9 @@ if is_mode("debug") then
 | 
				
			|||||||
    -- add_cxxflags("-O2","-DOI")
 | 
					    -- add_cxxflags("-O2","-DOI")
 | 
				
			||||||
    add_cxxflags("-DOI")
 | 
					    add_cxxflags("-DOI")
 | 
				
			||||||
end 
 | 
					end 
 | 
				
			||||||
 | 
					if is_mode("release") then 
 | 
				
			||||||
 | 
					    -- add_cxxflags("-march=native")
 | 
				
			||||||
 | 
					end 
 | 
				
			||||||
set_languages("c++17")
 | 
					set_languages("c++17")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
target("P1158")
 | 
					target("P1158")
 | 
				
			||||||
@ -19,4 +22,7 @@ target("lq14jd")
 | 
				
			|||||||
    add_files("20240823/十四届蓝桥比赛/简单算术题.cpp")
 | 
					    add_files("20240823/十四届蓝桥比赛/简单算术题.cpp")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
target("lq14sd")
 | 
					target("lq14sd")
 | 
				
			||||||
    add_files("20240823/十四届蓝桥比赛/数独填数.cpp")
 | 
					    add_files("20240823/十四届蓝桥比赛/数独填数.cpp")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					target("P2615")
 | 
				
			||||||
 | 
					    add_files("20240828/P2615/P2615.cpp")
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user