ASC45 Analogous Sets
来源:互联网 发布:四大网络小说 编辑:程序博客网 时间:2024/06/10 21:50
题目描述:
Problem A. Analogous Sets
Input le: analogous.in
Output le: analogous.out
Time limit: 2 seconds
Memory limit: 512 mebibytes
For a set A of positive integers let us call A + A a multiset {x + y | x, y ∈ A, x ̸= y}.
Consider two sets A and B of the same size n containing positive integers. A and B are called analogous
if A + A and B + B are the same multisets. For example, {1, 4} and {2, 3} are analogous, because
A + A = B + B = {5}, but {1, 2, 5, 6} and {1, 3, 4, 6} are not, because A + A = {3, 6, 7, 7, 8, 11} and
B + B = {4, 5, 7, 7, 9, 10}.
Given n you have to nd two analogous sets of size n or detect that there are none.
Input
The input le contains multiple test cases, one on a line.
Each test case is an integer n on a line by itself (2 ≤ n ≤ 1000).
The last test case is followed by a zero that should not be processed.
Output
For each test case print Yes if there exist two dierent analogous sets of size n, or No if there are
none. If there exist such sets, the following two lines must contain n positive integers each and describe
the found sets.
If there are several possible pairs of analogous sets for some n, you can output any one.
Example
analogous.in analogous.out
2
3
0
Yes
1 4
2 3
No
题解:
好题 吧..
首先很容易发现4个的交叉.然后我们发现了一个大概6个或者8个的,发现不对.这时候就要考虑到轮换对称平衡感觉** 所以写出来是中心对称的感觉.
其实就是上下交叉重复. 想不出来什么好的并且直观有用的证法
重点:
轮换对称是一种很重要的对称. 轮流拷贝+2的幂次也是应该去想的
代码:
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <vector>using namespace std;int n;vector<int> a[2];void solve(){ int flag = 0; for(int i = 1; i <= 10; i++) { if((1 << i) == n) { flag = 1; break; } } if(flag == 0) { printf("No\n"); return; } else { printf("Yes\n"); a[0].clear(); a[1].clear(); a[0].push_back(1); a[0].push_back(4); a[1].push_back(2); a[1].push_back(3); for(int i = 2; (1 << i) <= n; i++) { int last = (1 << (i)); int t = a[0].size(); for(int j = 0; j < t; j++) { a[0].push_back(last + a[1][j]); a[1].push_back(last + a[0][j]); } } for(int i = 0; i < a[0].size(); i++) { printf("%d ", a[0][i]); } printf("\n"); for(int i = 0; i < a[1].size(); i++) { printf("%d ", a[1][i]); } printf("\n"); }}int main(){ //freopen("A.txt", "r", stdin); freopen("analogous.in", "r", stdin); freopen("analogous.out", "w", stdout); while(scanf("%d", &n) && n) { solve(); } return 0;}
- ASC45 Analogous Sets
- Sets
- grouping sets
- C++ Sets
- Data Sets
- Disjoint Sets
- erlang sets
- grouping sets
- Guava ---- Sets
- Infinite sets
- c++ sets
- POJ_2082_Terrible Sets
- Generating Sets
- C++ Sets
- POJ_2082_Terrible Sets
- Scala Sets
- POJ_2082Terrible Sets
- Terrible Sets
- 手动安装liberty版本openstack环境(allinone)---安装nova
- Tracking
- [Ora]TNS-12537报错解决方法
- 临阵磨枪,血拼季网站优化的最后三板斧
- Building Simulation Packet-Loss System in Channel
- ASC45 Analogous Sets
- 黑马程序员--匿名内部类问题
- 读《VBScript程序员参考手册》,做的笔记
- Error while loading PyV8 binary:exit code 3
- 安装memcached及其扩展
- logback配置代码片段
- 芯片巨头为何痴恋开源软件?英特尔Imad Sousou来解密
- mysql(5.6.24)+Navicat Premium(11.1.13) 安装
- iOS 8新特性—— UIAlertController