1

bai123 暗区传说 2024-01-20 12:04:23 2024-01-20 12:04:34 2
#include <bits/stdc++.h>
using namespace std;
long long sum,a[1000005]; 
int n;
int main(){     
	cin>>n;
	a[1]=1;
	for(int i=2;i<=n;i++){
		a[i]=a[i-1]+i;	
		sum+=a[i];
	}
	cout<<sum;
	return 0;
}

{{ vote && vote.total.up }}

共 2 条回复

bai123 暗区传说
#include <bits/stdc++.h>
using namespace std;
int n,na,nb;// N 次猜拳
int a[205],b[205];
int main(){
	cin>>n>>na>>nb;
	for(int i=0;i<=na-1; i++)cin>>a[i];
	for(int i=0;i<=nb-1; i++)cin>>b[i];
	for(int i=0;i<n-1;i++){
		cout<<a[i%na]<<" "<<b[i%nb]<<endl;
		
	}
	return 0;
}
bai123 暗区传说
#include <bits/stdc++.h>
using namespace std;
int n,x=1,y=n/2+1;
int a[50][50];
int main(){
	cin>>n;
	int x=1,y=n/2+1;
	//1.填数字1
	a[1][n/2+1]=1;
	for(int i=2;i<=n*n;i++){//表示数字k 
		if(x==1&&y!=n){
			x=n,y=y+1;
		}else if(x!=1&&y==n){
			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; 
		}
	}
	return 0;
}