NC200488. Magic necklace
描述
There was a magic necklace. The necklace is made of magical gems numbered 1 through n. Unfortunately, the necklace was accidentally broken yesterday. Every gem was scattered on the ground.
输入描述
The first line of the input contains one integer t — the number of test cases.(t ≤ 110)The next t lines contain test cases. Each line contains a positive integer n(0 ≤ n ≤ 11)describing a test case.
输出描述
For each test case, output a line containing an integer which indicates the answer.
示例1
输入:
3 1 2 5
输出:
1 0 1
说明:
C++14(g++5.4) 解法, 执行用时: 3ms, 内存消耗: 484K, 提交时间: 2019-12-28 16:30:25
#include <bits/stdc++.h> using namespace std; int a[15]={0,1,0,0,0,1,5,33,245,2053,19137,196705}; int main() { int T,n; scanf("%d",&T); while(T--) { scanf("%d",&n); printf("%d\n",a[n]); } return 0; }
C++11(clang++ 3.9) 解法, 执行用时: 4ms, 内存消耗: 620K, 提交时间: 2019-12-28 17:03:43
#include <cstdio> int t,n; int a[11]={1,0,0,0,1,5,33,245,2053,19137,196705}; int main() { scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%d\n",a[n-1]); } return 0; }
Python3 解法, 执行用时: 46ms, 内存消耗: 4560K, 提交时间: 2022-03-25 15:08:39
a=[0,1,0,0,0,1,5,33,245,2053,19137,196705] for _ in range(int(input())): n=int(input()) print(a[n])