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 ...
随机推荐
- 数字证书中keytool命令使用说明
这个命令一般在JDK\jre\lib\security\目录下操作 keytool常用命令 -alias 产生别名 -keystore 指定密钥库的名称(就像数据库一样的证书库,可以 ...
- Gmail上不去怎么办?
近期非常多人反映Gmail上不去.每到重大政治事件附近,国家的防火墙就会加固一些. 事实上仅仅要下一个软件就能够轻松解决Google.Gmail上不去的问题. 下载地址 下载解压后点击"我要 ...
- Nginx性能测试
环境:Centos 7.0 Nginx 1.6.2 测试工具:siege 3.0.7 配置1: I3-3110M 4G 测试1(100用户,1000请求): 平均响应:0.06s 并发数:59.19 ...
- eolinker开源版接口管理
eolinker开源版接口管理 想找一个API接口管理的软件,为了安全性和扩展性考虑,希望是开源的,而且可以在内网独立部署.网上翻找了资料,经过一份比对之后,最终采用eolinker.过去有使用过RA ...
- HTML5实现两个视频循环播放!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 三分钟教你学Git(十二) 之 fast-forward
什么是fast forward, 顾名思义,就是高速向前进,Git怎么做到高速的呢? 原来假设Git判定能够fast forward的时候,直接改动当前HEAD指针的指向然后再改动当前HEAD指针.说 ...
- Android NDK开发初步
在配置好NDK开发之后就能够使用C/C++开发android了.以下以一个HelloWorld项目来说明 1.新建一个Androidproject 新建一个HelloWorldproject 代码例如 ...
- JS 之 数据类型转换
首先我们来简单了解一下JS中的数据类型,JavaScript拥有字符串.数字.布尔.数组.对象.Null.Undefiend 6中数据类型.同一时候,JavaScript拥有动态类型. 也 ...
- Spring属性编辑器详解
1.常见的属性的注入:int,string,list,set,map 2.什么是属性编辑器及作用? (1)将spring配置文件中的字符串转换为相应的java对象 (2)spring内置了一些属性编辑 ...
- POJ3182 The Grove[射线法+分层图最短路]
The Grove Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 904 Accepted: 444 Descripti ...