CF352A Jeff and Digits】的更多相关文章

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…
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…
更好的阅读体验 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/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…
C. Jeff and Rounding time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jeff got 2n real numbers a1, a2, ..., a2n as a birthday present. The boy hates non-integer numbers, so he decided to sli…
C. Jeff and Rounding time limit per test:  1 second memory limit per test: 256 megabytes input: standard input output: standard output Jeff got 2n real numbers a1, a2, ..., a2n as a birthday present. The boy hates non-integer numbers, so he decided t…
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…
Jeff got 2n real numbers a1, a2, ..., a2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly "adjust" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows: choose i…