陈老师的多校联合 20140809 C题
2014-08-09 21:19
393 查看
http://vjudge.net/contest/view.action?cid=51408#problem/C
Description
You live in the universe X where all the physical laws and constants are different from ours. For example all of their objects are N-dimensional. The living beings of the universe
X want to build an N-dimensional monument. We can consider this N dimensional monument as an N-dimensional hyper-box, which can be divided into some N dimensional
hypercells. The length of each of the sides of a hyper-cell is one. They will use some N-dimensional bricks (or hyper-bricks) to build this monument. But the length of each of the Nsides
of a brick cannot be anything other than fibonacci numbers. A fibonacci sequence is given below:
[align=center]1, 2, 3, 5, 8, 13, 21...[/align]
As you can see each value starting from 3 is the sum of previous 2 values. So for N = 3 they can use bricks of sizes (2,5,3), (5,2,2) etc. but they cannot use bricks of size
(1,2,4) because the length 4 is not a fibonacci number. Now given the length of each of the dimension of the monument determine the minimum number of hyper-bricks required to build the monument. No two hyper-bricks should intersect with each other or should
not go out of the hyper-box region of the monument. Also none of the hyper-cells of the monument should be empty.
Input
First line of the input file is an integer T(1
T
100) which
denotes the number of test cases. Each test case starts with a line containingN(1
N
15) that
denotes the dimension of the monument and the bricks. Next line contains N integers the length in each dimension. Each of these integers will be between 1 and 2000000000 inclusive.
Output
For each test case output contains a line in the format Casex:M where x is the case
number (starting from 1) and M is the minimum number of hyper-bricks required to build the monument.
Sample Input
Sample Output
题目大意:n维几何体,判断至少用多少n维且各维边长都为Fibonacci数的砖。
解题思路:求出n个数每个数至少是几个个Fibonacci数(可以重复)的和,然后这样把n个数的统计数乘起来就是答案。
Description
You live in the universe X where all the physical laws and constants are different from ours. For example all of their objects are N-dimensional. The living beings of the universe
X want to build an N-dimensional monument. We can consider this N dimensional monument as an N-dimensional hyper-box, which can be divided into some N dimensional
hypercells. The length of each of the sides of a hyper-cell is one. They will use some N-dimensional bricks (or hyper-bricks) to build this monument. But the length of each of the Nsides
of a brick cannot be anything other than fibonacci numbers. A fibonacci sequence is given below:
[align=center]1, 2, 3, 5, 8, 13, 21...[/align]
As you can see each value starting from 3 is the sum of previous 2 values. So for N = 3 they can use bricks of sizes (2,5,3), (5,2,2) etc. but they cannot use bricks of size
(1,2,4) because the length 4 is not a fibonacci number. Now given the length of each of the dimension of the monument determine the minimum number of hyper-bricks required to build the monument. No two hyper-bricks should intersect with each other or should
not go out of the hyper-box region of the monument. Also none of the hyper-cells of the monument should be empty.
Input
First line of the input file is an integer T(1
T
100) which
denotes the number of test cases. Each test case starts with a line containingN(1
N
15) that
denotes the dimension of the monument and the bricks. Next line contains N integers the length in each dimension. Each of these integers will be between 1 and 2000000000 inclusive.
Output
For each test case output contains a line in the format Casex:M where x is the case
number (starting from 1) and M is the minimum number of hyper-bricks required to build the monument.
Sample Input
2 2 4 4 3 5 7 8
Sample Output
Case 1: 4 Case 2: 2
题目大意:n维几何体,判断至少用多少n维且各维边长都为Fibonacci数的砖。
解题思路:求出n个数每个数至少是几个个Fibonacci数(可以重复)的和,然后这样把n个数的统计数乘起来就是答案。
#include <iostream> #include <cstring> #include <set> #include <cstdio> using namespace std; typedef long long LL; const int maxn =55; LL f[maxn],x[20]; set<LL>fib; set<LL>::iterator it; void init() { f[0]=1; f[1]=1; fib.insert(1); for(int i=2; i<maxn; i++) { f[i]=f[i-1]+f[i-2]; fib.insert(f[i]); } } int main() { int n,cas=1,t; scanf("%d",&t); while(t--) { scanf("%d",&n); for(int i=0; i<n; i++) scanf("%lld",&x[i]); init(); int i,j; long long ans=1; int cnt=1; for(i=0; i<n; i++) { //每个x[i]至少由几个斐波那契数组成(可以重复利用一个数多次) if(fib.find(x[i])==fib.end()) { cnt=1; int s=x[i]; while(fib.find(s)==fib.end()) { int t=lower_bound(f,f+55,s)-f; s=s-f[t-1]; cnt++; } ans*=cnt; } } printf("Case %d: %lld\n",cas++,ans); } return 0; }
相关文章推荐
- 陈老师的多校联合 20140809
- 陈老师的多校联合20140818||Uvalive 5683 模拟
- 陈老师的多校联合20140815 ||uvalive 5881 区间处理
- UVALive 5691 二分图匹配||陈老师的多校联合20140818 J题
- 陈老师的多校联合 I题 二分
- 陈老师的多校联合2010811c题||09年武汉站||hdu3232
- 陈老师的多校联合 D题 字符串处理起来挺麻烦
- 陈老师的多校联合2009年武汉站D题 ||hdu 3033
- 陈老师的多校联合20180808 map映射字符串
- 陈老师的多校联合20140811||HDU 3236 ||2009年武汉站G题 01背包问题
- 陈老师的多校联合20140816||spoj10237 bfs
- 陈老师的多校联合20140816A题||spoj 10228 动态规划
- 陈老师的多校联合 20140808 E题
- 陈老师的多校联合20140816||SPOJ AMR11B 三角形的有向面积
- HDU 5723 Abandoned country【2016多校联合】(最小生成树+深搜)
- 2016多校联合第三场 HDU5758 Explorer Bo
- [HDU5756] Boss Bo [2016 Multi-University Training Contest 3(2016多校联合训练3) E]
- HDOJ/HDU 3864 多校联合 D_num 数论
- HDU/HDOJ 3908 Triple 多校联合7
- 多校联合训练7&&HDU 5810