题解 CF734A 【Anton and Danik】】的更多相关文章

A. Anton and Danik 题目连接: http://codeforces.com/contest/734/problem/A Description Anton likes to play chess, and so does his friend Danik. Once they have played n games in a row. For each game it's known who was the winner - Anton or Danik. None of th…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Anton likes to play chess, and so does his friend Danik. Once they have played n games in a row. For each game it's known who was the winner - An…
Problem description Anton likes to play chess, and so does his friend Danik. Once they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie. Now Anton wonders, who won more gam…
本蒟蒻闲来无事刷刷水题 话说这道题,看楼下的大佬们基本都是用字符 ( char ) 来做的,那么我来介绍一下C++的优势: string ! string,也就是类型串,是C语言没有的,使用十分方便 我来介绍一下string的用法: 1.定义 string 字符串名; 2.输入 它有 2 种输入方式: ① getline\color{black}\text{getline}getline :使用方法: getline(cin,字符串名); ② cin\color{black}\text{cin}…
A. Anton and Danik time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anton likes to play chess, and so does his friend Danik. Once they have played n games in a row. For each game it's known…
A.Anton and Danik Problems: 给你长度为N的,只含'A','D'的序列,统计并输出何者出现的较多,相同为"Friendship" Analysis: lucky_ji: 水题,模拟统计A和D的数目比较大小输出结果即可 Tags: Implementation B.Anton and Digits Problems: 给定k2个2,k3个3,k5个5及k6个6,可以组成若干个32或256,求所有方案中Sigma的最大值 Analysis: lucky_ji: 同…
上次,我在" Anton And Danik "中为大家介绍了 string 的部分用法 今天,我就再来为大家介绍一下 string 的其他用法 : ( 有可能已经讲过了,不要介意 ) 1 . 定义 假设你想定义的字符串变量名字为 s ,那么就像下面一样定义 : string s; 而且,字符串还可以像数组一样定义: #define maxn 100010//定义元素个数的最大值,这里 maxn 为 100010 string s[maxn]; 或者直接 string s[100010…
题解 CF734F [Anton and School] 传送门 这种将位运算和普通运算结合起来的题目要拆位来考虑,可以得到\(log_{2}(\)值域\()\)的算法,甚至将值域看成常数. 根据 \(a|b+a \& b=a+b\) 得到 \(b_i+c_i=\Sigma a_i+na_i\) 于是 \(a_i=\frac{b_i+c_i- \Sigma a_i}{n}\) 根据这个式子,直接得到\(a_i\),注意在除的时候判断整除以免非法情况出现. 此时,我们要判断\(b_i\)和\(c_…
考虑用分块解决这个题,一次交换对当前逆序对个数的影响是,加上两倍的在区间\([l+1,r-1]\)中比\(a_r\)小的元素个数,减去两倍的在区间\([l+1,r-1]\)中比\(a_l\)小的元素个数,再根据\(a_l\)和\(a_r\)的大小关系决定这两个位置对答案的影响. 可以用\(vector\)来维护每个块内元素有序,然后就可以支持询问了. \(code:\) #include<bits/stdc++.h> #define maxn 200010 #define lower(a,x)…
Content 有 \(k_2\) 个 \(2\).\(k_3\) 个 \(3\).\(k_5\) 个 \(5\) 和 \(k_6\) 个 \(6\),你可以用这里面的数字来组成 \(256,32\) 两种数字,试求出组成数字的总和的最大值. 数据范围:\(0\leqslant k_2,k_3,k_5,k_6\leqslant 5\times 10^6\). Solution 我们很容易想到这样一个贪心的思路:先尽可能多地组合成 \(256\),在尽可能多地组成 \(32\). 所以,我们先看能…