素數環

素數環 題目: 給定1到n的數字中,將數字依次填入環中,使得任意相鄰的數字之和爲素數。 要求第一個數爲1,輸入的數n爲1<n<17 #include<stdio.h> using namespace std; int ans[22]; //保存環中的每一個被放入的數 bool hash[22]; int n; //判斷一個數是否爲素數,輸入不大於16,故兩數之和必在該數組內 int prim
相關文章
相關標籤/搜索