A. Jeff and Digits(cf)】的更多相关文章

A. Jeff and Digits time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so…
http://codeforces.com/contest/352/problem/A #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int n; ]; int main() { ,t2=; scanf("%d",&n); ; i<=n; i++) { scanf("%d",&a[i]); ) t1…
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got? Jeff must…
B. Jeff and Periods time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day Jeff got hold of an integer sequence a1, a2, ..., an of length n. The boy immediately decided to analyze the sequ…
更好的阅读体验 Portal Portal1: Codeforces Portal2: Luogu Description Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number div…
题目链接:http://codeforces.com/problemset/problem/352/A 题目意思:给定一个只有0或5组成的序列,你要重新编排这个序列(当然你可以不取尽这些数字),使得这个序列尽可能地大,并且能被90除尽. 做这道题目,是多次调试本场比赛的B,完全不成功后回头再做的,一开始什么思路都没有,因为觉得是考纯数学,直接看B......怎么说,很大程度是靠直觉的.只知道,这个序列肯定是这种形式:5xx...0 或者像题目所说的特殊情况:0(不过前提是0的个数不为0).其他就…
因为数字只含有5或0,如果要被90整除的话必须含有0,否则输出-1 如果含有0的话,就只需考虑组合的数字之和是9的倍数,只需要看最大的5的个数能否被9整数 #include <iostream> #include <vector> using namespace std; int main(){ int n; cin >> n; , numOfFive = ,tmp; ; i < n; ++ i){ cin>>tmp; ( tmp == ) ? (++…
http://codeforces.com/problemset/problem/351/A 题意: 2*n个数,选n个数上取整,n个数下取整 最小化 abs(取整之后数的和-原来数的和) 先使所有的数都下取整,累积更改的sum 那么选1个小数上取整,就会使sum-1 整数上下取整不会产生影响 所以有1个整数就可以使上取整的小数少1个 所以ans=min(abs(i-sum)) i∈[n-整数个数,n] #include<cmath> #include<cstdio> #inclu…
http://codeforces.com/contest/351/problem/E 题意: 给出一些数,可以改变任意数的正负,使序列的逆序对数量最少 因为可以任意加负号,所以可以先把所有数看作正数 序列中的数无论怎么改,都不会改变与绝对值最大的数的逆序对的数量 所以从绝对值最大的数开始,决定它的正负 若这个序列中没有重复的最大值 若i是正数,与右边比他小的形成逆序对 若i是负数,与左边比他小的形成逆序对 所以两边取较小的 若序列中出现重复的最大值 那么最优解的最大值一定是 先是若干个负数,然…
http://codeforces.com/contest/351/problem/B 题意: 给出一个n的排列 第一个人任选两个相邻数交换位置 第二个人有一半的概率交换相邻的第一个数>第二个数的位置:有一半的概率交换相邻第一个数<第二个数的位置 然后两人轮换 问使序列升序,期望最少操作次数 序列升序即逆序对数为0 dp[i]表示 当前逆序对还剩i对时,先手期望最少操作次数 先手在最优解的情况下一定交换 第一个数>第二个数的位置,即减少1个逆序对 后手等概率增加或减少1个逆序对 dp[i…