AIM Tech Round 4 (Div. 2)
分析:暴力
#include "iostream"
#include "cstdio"
#include "cstring"
#include "string"
using namespace std;
const int maxn=+;
int vis[maxn],n;
string s;
int main()
{
cin>>s;
cin>>n;
int len=s.length();
for(int i=;i<len;i++){
vis[s[i]-'a']++;
}
if(len<n){
cout<<"impossible"<<endl;
}else{
int num=;
for(int i=;i<;i++){
if(vis[i])
num++;
}
if(num>=n)
cout<<""<<endl;
else
cout<<(n-num)<<endl;
}
return ;
}
分析:求不同set的个数,同一个set的元素必须相同,而且是同一行,同一列的。所以对每行,每列,求有多少个0,多少个1,然后集合个数位(2^k-1),最后所有的单个元素都被算了两次,所以最后结果在减去n*m
#include "iostream"
#include "cstdio"
#include "cstring"
#include "string"
#include "vector"
#include "cmath"
using namespace std;
const int maxn=+;
int n,m;
int a[maxn][maxn];
struct Node
{
int zero,one;
};
vector<Node>p;
int main()
{
cin>>n>>m;
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
cin>>a[i][j];
for(int i=;i<=n;i++){
int num0=,num1=;
for(int j=;j<=m;j++){
if(a[i][j]==)
num1++;
else
num0++;
}
Node e;
e.zero=num0,e.one=num1;
p.push_back(e);
}
for(int j=;j<=m;j++){
int num0=,num1=;
for(int i=;i<=n;i++){
if(a[i][j]==)
num1++;
else
num0++;
}
Node r;
r.zero=num0,r.one=num1;
p.push_back(r);
}
long long res=;
for(int i=;i<p.size();i++){
res+=(long long)pow(,p[i].zero)-(long long);
res+=(long long)pow(,p[i].one)-(long long);
}
res-=(n*m);
cout<<res<<endl;
return ;
}
AIM Tech Round 4 (Div. 2)的更多相关文章
- codeforce AIM tech Round 4 div 2 B rectangles
2017-08-25 15:32:14 writer:pprp 题目: B. Rectangles time limit per test 1 second memory limit per test ...
- AIM Tech Round 3 (Div. 2)
#include <iostream> using namespace std; ]; int main() { int n, b, d; cin >> n >> ...
- AIM Tech Round 3 (Div. 2) A B C D
虽然打的时候是深夜但是状态比较好 但还是犯了好多错误..加分场愣是打成了降分场 ABC都比较水 一会敲完去看D 很快的就想出了求0和1个数的办法 然后一直wa在第四组..快结束的时候B因为低级错误被h ...
- AIM Tech Round 3 (Div. 2) B
Description Vasya takes part in the orienteering competition. There are n checkpoints located along ...
- AIM Tech Round 3 (Div. 2) A
Description Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Ko ...
- AIM Tech Round 3 (Div. 2) (B C D E) (codeforces 709B 709C 709D 709E)
rating又掉下去了.好不容易蓝了.... A..没读懂题,wa了好几次,明天问队友补上... B. Checkpoints 题意:一条直线上n个点x1,x2...xn,现在在位置a,求要经过任意n ...
- AIM Tech Round 3 (Div. 2) B 数学+贪心
http://codeforces.com/contest/709 题目大意:给一个一维的坐标轴,上面有n个点,我们刚开始在位置a,问,从a点开始走,走n-1个点所需要的最小路程. 思路:我们知道,如 ...
- AIM Tech Round 3 (Div. 2)D. Recover the String(贪心+字符串)
D. Recover the String time limit per test 1 second memory limit per test 256 megabytes input standar ...
- AIM Tech Round 4 (Div. 2)ABCD
A. Diversity time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- AIM Tech Round 4 (Div. 2)(A,暴力,B,组合数,C,STL+排序)
A. Diversity time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...
随机推荐
- VS2010编译OpenSSL(两个版本)
第一个版本: 编译工具 VS2010 OpenSSL版本 openssl-1.0.0a 下载 OpenSSL http://www.openssl.org/ 下载 from http://www.ac ...
- Arrays.asList引起的java.lang.UnsupportedOperationException解决方法
在项目中对List进行操作时报错java.lang.UnsupportedOperationException,后来发现操作的List是由数组转换而成的,通过看源码发现问题,并写测试程序如下. 代码块 ...
- H5缓存机制学习记录
参考文章:http://mp.weixin.qq.com/s?__biz=MTEwNTM0ODI0MQ==&mid=404724239&idx=1&sn=e0a2887f9ff ...
- js 中的 prototype 和 constructor
var a=function(){ this.msg="aa"; } a.prototype.say=function(){ alert('this is say');} 1.只有 ...
- Zabbix-20160817-高危SQL注入漏洞
漏洞概述: zabbix是一个开源的企业级性能监控解决方案.近日,zabbix的jsrpc的profileIdx2参数存在insert方式的SQL注入漏洞,攻击者无需授权登陆即可登陆zabbix管理系 ...
- ssh无密码登陆屌丝指南
[0]写在前面 由于ssh 实现的是免密码登陆,大致步骤是: 0.1) client通过ssh登陆到server: 0.2) server检查家目录下的.ssh文件, 并发送公钥文件 authoriz ...
- POJ 1840 Eqs(hash)
题意 输入a1,a2,a3,a4,a5 求有多少种不同的x1,x2,x3,x4,x5序列使得等式成立 a,x取值在-50到50之间 直接暴力的话肯定会超时的 100的五次方 10e了都 ...
- 【EDAS问题】轻量级EDAS部署hsf服务出现找不到类的解决方案
本地运行轻量级EDAS调用服务的时候报错如下: 2018-01-08 13:16:58.029 WARN [http-bio-8090-exec-8:t.hsf] [RPC Protocol call ...
- HDU 5379 Mahjong tree(树的遍历&组合数学)
本文纯属原创,转载请注明出处.谢谢. http://blog.csdn.net/zip_fan 题目传送门:http://acm.hdu.edu.cn/showproblem.php? pid=537 ...
- android菜鸟学习笔记6----android布局(一)
Android应用的UI组件都是继承自View类,View类表示的就是一个空白的矩形区域.常用的组件如TextView.Button.EditText等都直接或间接继承自View. 此外,View还有 ...