Submission #35351769


Source Code Expand

#include <cstdio>
using namespace std;
int cnt=0,n;
void otp(const int x){
	printf("%d ",x);
	if(++cnt==n)
		cnt=0,putchar('\n');
}
int main(){
	scanf("%d",&n);
	const int m=n*n;
	if(n>=6){
		for(int i=1; i<=m; i+=2)
			if(i>6*n-5||(i%3!=1))
				otp(i);
		for(int i=0; i<n; ++i)
			otp(6*i+1);
		for(int i=n; i; --i)
			otp(6*i-4);
		for(int i=2; i<=m; i+=2)
			if(i>6*n-4||(i%3!=2))
				otp(i);
		return 0;
	}
	if(n==3){
		puts("9 5 4");
		puts("3 7 2");
		puts("1 8 6");
		return 0;
	}
	if(n==4){
		puts("9 1 8 10");
		puts("11 7 2 12");
		puts("13 3 6 14");
		puts("15 5 4 16");
		return 0;
	}
	if(n==5){
		puts("11 13 9 6 24");
		puts("15 17 5 4 22");
		puts("19 21 7 2 20");
		puts("23 1 8 14 16");
		puts("25 3 12 10 18");
		return 0;
	}
	return 0;
}

Submission Info

Submission Time
Task C - Avoid Prime Sum
User wangzhifang
Language C++ (GCC 9.2.1)
Score 500
Code Size 802 Byte
Status AC
Exec Time 86 ms
Memory 7188 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:10:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   10 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 1
AC × 24
Set Name Test Cases
Sample 01_sample_01.txt
All 01_sample_01.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 02_small_06.txt, 02_small_07.txt, 02_small_08.txt, 03_rand_01.txt, 03_rand_02.txt, 03_rand_03.txt, 03_rand_04.txt, 03_rand_05.txt, 03_rand_06.txt, 03_rand_07.txt, 03_rand_08.txt, 03_rand_09.txt, 03_rand_10.txt, 04_max_01.txt, 04_max_02.txt, 04_max_03.txt, 04_max_04.txt, 04_max_05.txt
Case Name Status Exec Time Memory
01_sample_01.txt AC 5 ms 1576 KiB
02_small_01.txt AC 1 ms 1576 KiB
02_small_02.txt AC 2 ms 1584 KiB
02_small_03.txt AC 1 ms 1580 KiB
02_small_04.txt AC 1 ms 1708 KiB
02_small_05.txt AC 3 ms 1636 KiB
02_small_06.txt AC 1 ms 1644 KiB
02_small_07.txt AC 3 ms 1712 KiB
02_small_08.txt AC 1 ms 1624 KiB
03_rand_01.txt AC 52 ms 3960 KiB
03_rand_02.txt AC 9 ms 1644 KiB
03_rand_03.txt AC 13 ms 1612 KiB
03_rand_04.txt AC 21 ms 1640 KiB
03_rand_05.txt AC 71 ms 5652 KiB
03_rand_06.txt AC 18 ms 1656 KiB
03_rand_07.txt AC 61 ms 4896 KiB
03_rand_08.txt AC 17 ms 1616 KiB
03_rand_09.txt AC 46 ms 3176 KiB
03_rand_10.txt AC 12 ms 1636 KiB
04_max_01.txt AC 84 ms 7148 KiB
04_max_02.txt AC 86 ms 7144 KiB
04_max_03.txt AC 82 ms 7168 KiB
04_max_04.txt AC 86 ms 7124 KiB
04_max_05.txt AC 86 ms 7188 KiB