https://codeforces.com/contest/1181/problem/B 从中间拆开然后用大数搞一波. 当时没想清楚奇偶是怎么弄,其实都可以,奇数长度字符串的中心就在len/2,偶数长度字符串的中心恰好是len/2和len/2-1. 但是要是作为末尾指针的位置来说的话 奇数长度字符串:把中心分给后半串,那么分割点是len/2.把中心分给前半串,那么分割点是len/2+1. 偶数长度字符串:分割点是len/2. 注意子串的取法,其实最方便的还是传头尾指针进去. #include<…
题目描述: time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Dima worked all day and wrote down on a long paper strip his favorite number n consisting of l digits. Unfortunately, the strip turned…
B. Split a Number time limit per test2 seconds memory limit per test512 megabytes inputstandard input outputstandard output Dima worked all day and wrote down on a long paper strip his favorite number n consisting of l digits. Unfortunately, the stri…
Split a Number time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Dima worked all day and wrote down on a long paper strip his favorite number nn consisting of ll digits. Unfortunately, the s…
You are given an integer x. Your task is to split the number x into exactly n strictly positive integers such that the difference between the largest and smallest integer among them is as minimal as possible. Can you? Input The first line contains an…
题目:http://codeforces.com/gym/100338/attachments 贪心,每次枚举10的i次幂,除k后取余数r在用k-r补在10的幂上作为候选答案. #include<bits/stdc++.h> using namespace std; typedef unsigned long long ull; ; ull base[maxbit], n, k; void preDeal() { ] = ; ; i < maxbit; i++){ *]; } } voi…
[Codeforces 1214A]Optimal Currency Exchange(贪心) 题面 题面较长,略 分析 这个A题稍微有点思维难度,比赛的时候被孙了一下 贪心的思路是,我们换面值越小的货币越优.如有1,2,5,10,20,50,那么我们尽量用面值为1的.如果我们把原始货币换成面值为x的货币,设汇率为d,那么需要的原始货币为dx的倍数.显然dx越小,剩下的钱,即n取模dx会尽量小. 然后就可以枚举换某一种货币的数量,时间复杂度\(O(\frac{n}{d})\) 代码 #inclu…
Dima worked all day and wrote down on a long paper strip his favorite number nn consisting of ll digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. To solve the issue, Dima decided to split the strip…
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, …
\(>Codeforces \space 980 E. The Number Games<\) 题目大意 : 有一棵点数为 \(n\) 的数,第 \(i\) 个点的点权是 \(2^i\) 你需要删掉 \(k\) 个点,使得删掉这些点后树依然联通,且剩下的点权之和最大,并输出方案 \(n , k \leq 10^6\) 解题思路 : 问题可以转化为选取 \(n - k\) 个点,使得选取的点联通且权值和最大 根据点权是 \(2^i\) 的性质,显然有选取编号为 \(x\) 的点比选取 \(i =…