博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2014 ACM-ICPC Beijing Invitational Programming Contest
阅读量:5305 次
发布时间:2019-06-14

本文共 3305 字,大约阅读时间需要 11 分钟。

Happy Reversal

Time Limit: 1000ms
Memory Limit: 65536KB
64-bit integer IO format: 
%lld      Java class name: 
Main
         
Font Size: 
+  
-
Type:  NoneGraph Theory     2-SAT    Articulation/Bridge/Biconnected Component     Cycles/Topological Sorting/Strongly Connected Component     Shortest Path         Bellman Ford        Dijkstra/Floyd Warshall     Euler Trail/Circuit     Heavy-Light Decomposition     Minimum Spanning Tree     Stable Marriage Problem     Trees     Directed Minimum Spanning Tree     Flow/Matching        Graph Matching             Bipartite Matching             Hopcroft–Karp Bipartite Matching             Weighted Bipartite Matching/Hungarian Algorithm         Flow             Max Flow/Min Cut             Min Cost Max Flow DFS-like    Backtracking with Pruning/Branch and Bound     Basic Recursion     IDA* Search    Parsing/Grammar     Breadth First Search/Depth First Search     Advanced Search Techniques         Binary Search/Bisection         Ternary Search Geometry     Basic Geometry    Computational Geometry     Convex Hull     Pick's TheoremGame Theory     Green Hackenbush/Colon Principle/Fusion Principle     Nim     Sprague-Grundy Number Matrix    Gaussian Elimination     Matrix Exponentiation Data Structures     Basic Data Structures     Binary Indexed Tree     Binary Search Tree     Hashing    Orthogonal Range Search     Range Minimum Query/Lowest Common Ancestor     Segment Tree/Interval Tree     Trie Tree     Sorting    Disjoint Set String     Aho Corasick    Knuth-Morris-Pratt     Suffix Array/Suffix Tree Math     Basic Math    Big Integer Arithmetic     Number Theory         Chinese Remainder Theorem         Extended Euclid         Inclusion/Exclusion         Modular Arithmetic     Combinatorics        Group Theory/Burnside's lemma         Counting     Probability/Expected Value Others    Tricky     Hardest    Unusual     Brute Force     Implementation    Constructive Algorithms     Two Pointer     Bitmask    Beginner     Discrete Logarithm/Shank's Baby-step Giant-step Algorithm     Greedy     Divide and Conquer Dynamic Programming
   
Tag it!
Elfness is studying in an operation "
NOT".
For a binary number A, if we do operation "
NOT A", after that, all digits of A will be reversed. (e.g. A=
1001101, after operation "
NOT A", A will be 
0110010).
Now Elfness has N binary numbers of length K, now he can do operations "
NOT" for some of his numbers. 
Let's assume after his operations, the maximum number is M, the minimum number is P. He wants to know what's the maximum M - P he can get. Can you help him?

 

Input

The first line of input is an integer T (T ≤ 60), indicating the number of cases.
For each case, the first line contains 2 integers N (1 ≤ N ≤ 10000) and K (1 ≤ K ≤ 60), the next N lines contains N binary numbers, one number per line, indicating the numbers that Elfness has. The length of each binary number is K.
 

Output

For each case, first output the case number as "Case #x: ", and x is the case number. Then you should output an integer, indicating the maximum result that Elfness can get.

Sample Input

25 61001000011000100010100011111115 700011010001011001001101110001001011

Sample Output

Case #1: 51Case #2: 103

Source

给你n组由k个0或者1组成的二进制数。每一个数能够翻转。求两个数的最大差值。

//152 ms 1788 KB#include
#include
using namespace std;char s[107];long long ans[20007];int n,m;long long getnum(){ long long res=0,j=1; for(int i=m-1;i>=0;i--,j*=2) if(s[i]=='1')res+=j; return res;}int main(){ int t,cas=1; scanf("%d",&t); while(t--) { int k=0; scanf("%d%d",&n,&m); for(int i=0;i

转载于:https://www.cnblogs.com/ldxsuanfa/p/10029238.html

你可能感兴趣的文章
C++学习之智能指针
查看>>
python升级安装后的yum的修复
查看>>
Vim配置Node.js开发工具
查看>>
iOS开发者需要的5款排版工具
查看>>
web前端面试题2017
查看>>
Reflection in Teaching
查看>>
intellij idea 将模块打jar包
查看>>
给MySQL增加Sequence管理功能
查看>>
ELMAH——可插拔错误日志工具
查看>>
MySQL学习笔记(四)
查看>>
【Crash Course Psychology】2. Research & Experimentation笔记
查看>>
两数和
查看>>
Python subprocess 模块
查看>>
Http协议
查看>>
c#获取文件路径
查看>>
移动设备和SharePoint 2013 - 第3部分:推送通知
查看>>
SOPC Builder中SystemID
查看>>
MySQL数据库备份工具mysqldump的使用(转)
查看>>
SSL 1120——【USACO 2.4】回家[最短路]
查看>>
Python学习之路:新式类VS经典类
查看>>