URAL 1735 Theft of the Century

题意

有两种物品:白金和金子,单位重量分别为 x,y ,装在 n 个袋子里,每个袋子里物品种类相同,并且分别有m个。
现在要从每个袋子中拿出一些,一起称重,只能称一次,问是否一定能知道每个袋子里物品的种类是什么,如果可以,并输出方案。

题解

题目给定 x<y 。那么,事实上,称一次重,可能有 2n 种状态。
那么,原题转化为:
要求一个集合 S f(S)定义为 S 中元素的和,则有S的幂集所有 s f(s)互不相同,问 min{max(x|xS)}
可以在oeis上搜索Conway-Guy sequence。。。
Conway-Guy sequence: a(n + 1) = 2a(n) - a(n - floor( 1/2 + sqrt(2n) ))
Conway and Guy conjecture that the set of k numbers {s_i = a(k) - a(k-i) : 1 <= i <= k} has the property that all its subsets have distinct sums - see Guy’s book.
0, 1, 2, 4, 7, 13, 24, 44…
Triangle read by rows in which row n gives the n-set obtained as the differences {b(n)-b(n-i), 0 <= i <= n-1}, where b() = A005318().
{1}
{1,2}
{2,3,4}
{3,5,6,7}
{6,9,11,12,13}
{11,17,20,22,23,24}

。。。
恩,就是这样,这是一道数学题。。。

code

#include<cstdio>
#include<cmath>
const int maxn=100;

int n,k,x,y;

int a[maxn];

int main(){
    a[1]=1;
    for(int i=2;i<maxn;++i) a[i]=2*a[i-1]-a[(i-1)-(int)(0.5+sqrt(2*(i-1)))];

    scanf("%d%d%d%d",&n,&k,&x,&y);
    if (k<a[n]){ puts("NO"); return 0; }
    puts("YES");
    for(int i=1;i<=n;++i){
        printf("%d ",a[n]-a[n-i]);
    }
//  for(;;);
    return 0;
}
用代码解决这个问题The program committee of the school programming contests, which are often held at the Ural State University, is a big, joyful, and united team. In fact, they are so united that the time spent together at the university is not enough for them, so they often visit each other at their homes. In addition, they are quite athletic and like walking. Once the guardian of the traditions of the sports programming at the Ural State University decided that the members of the program committee spent too much time walking from home to home. They could have spent that time inventing and preparing new problems instead. To prove that, he wanted to calculate the average distance that the members of the program committee walked when they visited each other. The guardian took a map of Yekaterinburg, marked the houses of all the members of the program committee there, and wrote down their coordinates. However, there were so many coordinates that he wasn't able to solve that problem and asked for your help. The city of Yekaterinburg is a rectangle with the sides parallel to the coordinate axes. All the streets stretch from east to west or from north to south through the whole city, from one end to the other. The house of each member of the program committee is located strictly at the intersection of two orthogonal streets. It is known that all the members of the program committee walk only along the streets, because it is more pleasant to walk on sidewalks than on small courtyard paths. Of course, when walking from one house to another, they always choose the shortest way. All the members of the program committee visit each other equally often. Input The first line contains the number n of members of the program committee (2 ≤ n ≤ 105). The i-th of the following n lines contains space-separated coordinates xi, yi of the house of the i-th member of the program committee (1 ≤ xi, yi ≤ 106). All coordinates are integers. Output Output the average distance, rounded down to an integer, that a member of the program committee walks from his house to the house of his colleague.
05-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值