codeforces 596】的更多相关文章

题意:给你一个n和一个p,让你用 (2k+p)进制来表示n,找出用最少的(2k+p)来表示n. 分析:首先我们看到2k,首先下想到二进制,我们可以我们列出式子,也就是 (2x1 + p)+(2x2 + p)+(2x3 + p)+……+(2xk + p) == n 然后我们转换为  2x1 +2x2 +2x3 +……+2xk  == n- m*p 这样问题就转换为求 m的最小值是多少. 我们再分析,由于数据给出 n < 109  ,所以 m < 32. 这样我们就可以从小到大暴力枚举m的大小.…
C 题意 定义p-binary为2^x+p 现在给你一个数x,和一个p. 问你最少用多少个p-binary能构造出x,如果没有输出-1 题解 转化为: x = 2^x1 + 2^x2 + ... + 2^xn + n*p 首先我们知道任何数都能用二进制表示,如果p=0的话,肯定是有解的.那么答案最少都是x的2进制1的个数. 另外什么情况无解呢,即x-n*p<0的时候肯定无解,可以更加有优化为x-n*p<n的时候无解. 答案实际上就是n,我们从小到大枚举n,然后check现在的2进制中1的个数是…
A - Forgetting Things 题意:给 \(a,b\) 两个数字的开头数字(1~9),求使得等式 \(a=b-1\) 成立的一组 \(a,b\) ,无解输出-1. 题解:很显然只有 \(a=b\) 和 \(a=b-1\) 的时候有解,再加上一个从 \(9\) 越到 \(10\) 的就可以了.被样例的 \(199,200\) 误导了. #include<bits/stdc++.h> using namespace std; typedef long long ll; int mai…
链接: https://codeforces.com/contest/1247/problem/D 题意: You are given n positive integers a1,-,an, and an integer k≥2. Count the number of pairs i,j such that 1≤i<j≤n, and there exists an integer x such that ai⋅aj=xk. 思路: 对每个数质数拆分,记录质数的指数modk的值,map记录ve…
链接: https://codeforces.com/contest/1247/problem/C 题意: Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero). T…
链接: https://codeforces.com/contest/1247/problem/B2 题意: The only difference between easy and hard versions is constraints. The BerTV channel every day broadcasts one episode of one of the k TV shows. You know the schedule for the next n days: a sequen…
链接: https://codeforces.com/contest/1247/problem/A 题意: Kolya is very absent-minded. Today his math teacher asked him to solve a simple problem with the equation a+1=b with positive integers a and b, but Kolya forgot the numbers a and b. He does, howev…
万幸的是终于碰上了一场上分好场. 不幸的是一开始差点不会 A. 万幸的是想了个不那么稳的结论过了 pretest. 不幸的是罚时很高,而且慌得一比. 万幸的是然后半个小时内把 B 和 C 码了. 不幸的是然后就只能看着排名一点一点掉了. 万幸的是最后 A 没被叉掉. 不幸的是我居然没敢去叉人. 万幸的是我就是叉了 10 个人排名也不会上涨超过 5. 不幸的是我每掉一名都会少涨两三分. 万幸的是我没去打隔壁的 ZR. 不幸的是我发现这场 ZR 我一题不会,打了就会掉分-- 2A 没仔细想,但是应该…
F. Tree Factory Bytelandian Tree Factory produces trees for all kinds of industrial applications. You have been tasked with optimizing the production of a certain type of tree for an especially large and important order. The tree in question is a roo…
E. Rock Is Push You are at the top left cell (1,1) of an n×m labyrinth. Your goal is to get to the bottom right cell (n,m). You can only move right or down, one cell per step. Moving right from a cell (x,y) takes you to the cell (x,y+1), while moving…