A题

分析:暴力

 1 #include "iostream"
 2 #include "cstdio"
 3 #include "cstring"
 4 #include "string"
 5 using namespace std;
 6 const int maxn=100+10;
 7 int vis[maxn],n;
 8 string s;
 9 int main()
10 {
11     cin>>s;
12     cin>>n;
13     int len=s.length();
14     for(int i=0;i<len;i++){
15         vis[s[i]-'a']++;
16     }
17     if(len<n){
18         cout<<"impossible"<<endl;
19     }else{
20         int num=0;
21         for(int i=0;i<30;i++){
22             if(vis[i])
23                 num++;
24         }
25         if(num>=n)
26             cout<<"0"<<endl;
27         else
28             cout<<(n-num)<<endl;
29     }
30     return 0;
31 }

View Code

B题

分析:求不同set的个数,同一个set的元素必须相同,而且是同一行,同一列的。所以对每行,每列,求有多少个0,多少个1,然后集合个数位(2^k-1),最后所有的单个元素都被算了两次,所以最后结果在减去n*m

 1 #include "iostream"
 2 #include "cstdio"
 3 #include "cstring"
 4 #include "string"
 5 #include "vector"
 6 #include "cmath"
 7 using namespace std;
 8 const int maxn=100+10;
 9 int n,m;
10 int a[maxn][maxn];
11 struct Node
12 {
13     int zero,one;
14 };
15 vector<Node>p;
16 int main()
17 {
18     cin>>n>>m;
19     for(int i=1;i<=n;i++)
20         for(int j=1;j<=m;j++)
21             cin>>a[i][j];
22     for(int i=1;i<=n;i++){
23         int num0=0,num1=0;
24         for(int j=1;j<=m;j++){
25             if(a[i][j]==1)
26                 num1++;
27             else
28                 num0++;
29         }
30         Node e;
31         e.zero=num0,e.one=num1;
32         p.push_back(e);
33     }
34     for(int j=1;j<=m;j++){
35         int num0=0,num1=0;
36         for(int i=1;i<=n;i++){
37             if(a[i][j]==1)
38                 num1++;
39             else
40                 num0++;
41         }
42         Node r;
43         r.zero=num0,r.one=num1;
44         p.push_back(r);
45     }
46     long long res=0;
47     for(int i=0;i<p.size();i++){
48         res+=(long long)pow(2,p[i].zero)-(long long)1;
49         res+=(long long)pow(2,p[i].one)-(long long)1;
50     }
51     res-=(n*m);
52     cout<<res<<endl;
53     return 0;
54 }

View Code

转载于:https://www.cnblogs.com/wolf940509/p/7523375.html

AIM Tech Round 4 (Div. 2)相关推荐

  1. AIM Tech Round 4 (Div. 2)ABCD

    这一场真的是血崩,a,b都被hack,还好结束前重交都过了 A:题意:找出得到k个不同的字符,所要更改的最小字符数 题解:首先如果k>字符串长度,直接impossible,然后直接记录一下不重复 ...

  2. AIM Tech Round 3 (Div. 2) A B C D

    虽然打的时候是深夜但是状态比较好 但还是犯了好多错误..加分场愣是打成了降分场 ABC都比较水 一会敲完去看D 很快的就想出了求0和1个数的办法 然后一直wa在第四组..快结束的时候B因为低级错误被h ...

  3. AIM Tech Round (Div. 1) C. Electric Charges 二分

    C. Electric Charges 题目连接: http://www.codeforces.com/contest/623/problem/C Description Programmer Sas ...

  4. CF AIM Tech Round 5 (rated, Div. 1 + Div. 2) B. Unnatural Conditions 思维 ʕ •ᴥ•ʔ

    Let s(x)s(x) be sum of digits in decimal representation of positive integer xx. Given two integers n ...

  5. AIM Tech Round 5C. Rectangles 思维

    C. Rectangles time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  6. Codeforces Round #433(Div. 2) D. Jury Meeting(贪心)

    题目链接:Codeforces Round #433(Div. 2) D. Jury Meeting 题意: 有n个城市,每个城市有一个人,现在要让这些人来0号城市在一起k天,然后回去. 现在有m个日 ...

  7. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  8. Codeforces Round #563 (Div. 2)/CF1174

    Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...

  9. 构造 Codeforces Round #302 (Div. 2) B Sea and Islands

    题目传送门 1 /* 2 题意:在n^n的海洋里是否有k块陆地 3 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 4 输出完k个L后,之后全部输出S:) 5 5 10 的例子可以 ...

最新文章

  1. 特写李飞飞:她激励了人工智能的发展,更要给人工智能赋予人的价值
  2. anaconda mac安装
  3. Django静态文件处理、中间件及Admin站点
  4. SAP UI5 My Opportunity应用里的 currency validation
  5. [react-router] 请你说说react的路由的优缺点?
  6. html本地载入缓存文件,Flutter中如何加载并预览本地的html文件的方法
  7. 因更改注册表而导致无法打开QQ文件所在文件夹
  8. MySQL 对 CREATE TABLE IF NOT EXISTS SELECT 的处理
  9. python代码编写规范
  10. kafka消费者如何读同一生产者消息_Kafka系列3:深入理解Kafka消费者
  11. UVA148 ZOJ1166 Anagram checker【DFS】
  12. MySQL启动参数(三) —— table_open_cache
  13. 名字打架小游戏 java_闲暇极品MD5 能用名字打架的小游戏
  14. Linux升级glibc版本汉字乱码,glibc版本升级
  15. linux系统开启端口命令
  16. tomcat到底是干什么用的?白话理解
  17. 「笔耕不辍」zookeeper的节点加密方式及分布式锁实现过程
  18. Java Web3J概述
  19. ios 事件穿透的原因和解决方法
  20. Instruments相关

热门文章

  1. python从mongodb里取出数据进行可视化_Python数据分析及可视化实例之MongoDB增删改查...
  2. 普中科技51单片机_【笔记】普中科技-51单片机-静态数码管显示
  3. img 居中_解决img标签下方出现的小空隙
  4. 利用css设置使超链接不能点击或者失效
  5. linux arm. 快速启动,教你如何快速启动Linux 系统
  6. MVVM下拉框绑定触发事件
  7. python秒表游戏_数学游戏Tkinter中的Python计时器
  8. mysql索引 order by_MySQL 通过索引优化含ORDER BY的语句
  9. mysql可重复读实验_Mysql可重复读测试
  10. php mysql 非空_PHP-为什么mysql接受非空字段为null