Codeforces 336C
这题是大一暑假时候做的,当时没有出,直到今天突然觉得应该把没过的题目再做一边,不然真的是越积越多。
现在能够独立做出来真的是难以表达的兴奋,刚开始的时候就觉得 O(30 * 30 * n)的复杂度有点不安全,不过还是敲了,事实说明实际的负责度没这么高。和去年一样,没有思路,后来仔细一想,真的是数学题。现在感觉爱上了Math...
附上代码:
#include <cstdio>
#include <cstring> // 保存原始数组
int b[];
// a[i][j]表示b[i]的二进制表示法中的各个位上的数值, 而able数组保存的是每一轮中可以选的标记
bool a[][], able[];
int n; int main(void) {
while (~scanf("%d", &n) && n) {
memset(a, false, sizeof(a));
for (int i = ; i < n; i++) {
int x;
scanf("%d", &x);
b[i] = x;
for (int j = ; j >= ; j--) {
if (( << j) & x)
a[i][-j] = true;
}
} int cnt;
for (int i = ; i <= ; i++) {
cnt = ;
memset(able, false, sizeof(able));
for (int j = ; j < n; j++) {
if ( a[j][i] ) {
able[j] = true;
cnt++;
}
}
if (cnt == ) continue; int j;
for (j = i + ; j <= ; j++) {
int f = ;
for (int k = ; k < n; k++) {
if ( able[k] ) {
if ( !a[k][j] ) {
f = ;
break;
}
}
}
if (f == )
break;
}
if (j > )
break;
}
printf("%d\n", cnt);
int flag = ;
for (int i = ; i < n; i++) {
if ( able[i] ) {
if (flag)
printf(" ");
flag = ;
printf("%d", b[i]);
}
}
puts("");
} return ;
}
Codeforces 336C的更多相关文章
- codeforces 336C Vasily the Bear and Sequence(贪心)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Vasily the Bear and Sequence Vasily the b ...
- Codeforces 336C 0-1背包
题意:每个水果有两个值,一个美味度 a,一个卡路里 b,从中挑选一些,要求 sum(aj) / sum(bj) = k,使得 sum(a) 最大. 分析:没有那个条件就是一个01背包,可以转换,对公式 ...
- C. Vasily the Bear and Sequence Codeforces 336C(枚举,思维)
C. Vasily the Bear and Sequence time limit per test 1 second memory limit per test 256 megabytes inp ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
随机推荐
- 用Jmeter参数化实现接口自动化测试
本文记录如何使用Jmeter参数化(csv)实现接口自动化——测试Token不同入参情况下,接口请求能够返回正确的结果 1. 首先需要使用Jmeter获取一个Token,如何获取暂略(同一般访问请求方 ...
- day1(老男孩-Python3.5-S14期全栈开发)
作者:赵俊 发布日期:2019/10/18 一.第一个python程序 1.在解释器下写hello world程序运行,与运行外部文件方法 运行外部文件,必须在相应位置创建一个p ...
- TZOJ 5094 Stringsobits(DP)
描述 Consider an ordered set S of strings of N (1 <= N <= 31) bits. Bits, of course, are either ...
- 洛谷P5319 奥术神杖
题意:给你若干个串和一个填了一部分的串.补完这个串使得 (每个串的匹配次数 * 权值) ^ (1 / 所有串匹配次数) 最大. 解:把这个东西随便取一个对数,就变成了分数规划. 二分.然后在AC自动机 ...
- Django项目:CRM(客户关系管理系统)--43--35PerfectCRM实现CRM重写Admin密码修改
#admin.py # ————————01PerfectCRM基本配置ADMIN———————— from django.contrib import admin # Register your m ...
- CI框架 - Xhprof性能监控,用钩子hooks实现
安装Xhprof参考:http://www.cnblogs.com/qq917937712/p/8889001.html 第一步:配置config.php $config['enable_hooks' ...
- php mkdir 777失败
参考网址:https://www.cnblogs.com/52php/p/5660079.html 在linux系统中在创建文件/文件夹时有一个默认权限,此权限受 umask 设置影响,在/etc/b ...
- HTTP_REFERER的用法及伪造
引言 在php中,可以使用$_SERVER[‘HTTP_REFERER’]来获取HTTP_REFERER信息,关于HTTP_REFERER,php文档中的描述如下: “引导用户代理到当前页的前一页的地 ...
- java多线程三种方式
java多线程都有几种方式 有三种: (1)继承Thread类,重写run函数 创建: class xx extends Thread{ public void run(){ Thread.sleep ...
- 机房收费系统vb.net之打包与部署(二)
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/wangdan199112/article/details/28286365 ...