【Codeforces 1036C】Classy Numbers】的更多相关文章

[链接] 我是链接,点我呀:) [题意] 让你求出只由3个非0数字组成的数字在[li,ri]这个区间里面有多少个. [题解] 只由3个非0数字组成的数字在1~10^18中只有60W个 dfs处理出来之后排序做个二分查找一下区间里有多少个就好. [代码] import java.io.*; import java.util.*; public class Main { static InputReader in; static PrintWriter out; public static void…
[链接] 我是链接,点我呀:) [题意] 让你找到长度为n的数字 这个数字只由a或者b组成 且这n个数码的和也是由a或者b组成的 求出满足这样要求的数字的个数 [题解] 枚举答案数字中b的个数为y,那么a出现的个数就为n-y 那么和就是na + (b-a)y; 这个数字最多就7位的样子 很容易检查是不是只包含a或者b 然后如果满足只包含a或者b 则答案加上C(n,y) 即n个位置中选择y个放b,其他的放a 组合数取余的话,预处理一下阶乘以及阶乘的逆元就好 [代码] import java.io.…
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=2000),问满足[数列长度是k && 数列中每一个元素arr[i]在1~n之间 && 数列中元素可以重复]的数列有多少个?结果对10^9+7取余 解题思路:dp[i][j]表示长度是j,最后一位是i的种数 if(kk%i==0) dp[kk][j+1]+=dp[i][j] #inc…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famous Stolp's gears, pu…
[题目链接]:http://codeforces.com/problemset/problem/746/E [题意] 你有n张卡片,上面写着不同的数字; 然后另外一个人有m张上面写着不同的数字的卡片:卡片上的数字从1..m; 你可以和另外一个人交换卡片; 问你最少的交换次数; 使得你的n张卡片里面,卡片上的数字为奇数的和卡片上的数字为偶数的张数相同. 且这n张卡片不能有相同的数字; [题解] 首先考虑去重的工作; 在去重之前;先算出; 原来的n张卡片里面,卡片上的数字是奇数的数字个数odd; 然…
[题目链接]:http://codeforces.com/problemset/problem/367/C [题意] 我们称一个数列a[N]美丽; 当且仅当,数列中出现的每一对数字都有相邻的. 给你n的大小; 以及m个数字以及它们的使用花费; 问你最多能花费多少钱; 使得选择的这些数字能够构成一个长度为n的美丽数列; [题解] 显然选什么数字,只要是不一样的就可以了;和数字具体是什么无关; 要算出的就是最多能选几个数字N; 这里,数字的相邻关系能构成一张图; 完全图->每个点都与其他n-1个点有…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Roman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the tree, each of the n …
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art. The main…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output After Vitaly was expelled from the university, he became interested in the graph theory. Vitaly especially liked the cycles of an odd length in w…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Soon a school Olympiad in Informatics will be held in Berland, n schoolchildren will participate there. At a meeting of the jury of the Olympiad…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which co…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point valu…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Alyona has a tree with n vertices. The root of the tree is the vertex 1. In each vertex Alyona wrote an positive integer, in the vertex i she wr…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output People do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become a…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Chri…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Gerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought a special board to…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system i…
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic num…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Companies always have a lot of equipment, furniture and other things. All of them should be tracked. To do this, there is an inventory number ass…
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has decided to prepare…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Vanya got an important task - he should enumerate books in the library and label each book with its number. Each of the n books should be assigne…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output PolandBall is a young, clever Ball. He is interested in prime numbers. He has stated a following hypothesis: "There exists such a positive integ…
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve i…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Kleofáš is participating in an n-thlon - a tournament consisting of n different competitions in n different disciplines (numbered 1 through n). T…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output The country Treeland consists of n cities connected with n - 1 bidirectional roads in such a way that it's possible to reach every city starting…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given n numbers a1, a2, -, an. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We wan…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Anton loves transforming one permutation into another one by swapping elements for money, and Ira doesn't like paying for stupid games. Help them…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Gennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office. All chi…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the meth…