B. Little Elephant and Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant loves numbers. He has a positive integer x. The Little Elephant wants to find the number…
E. Little Elephant and Shifts time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant has two permutations a and b of length n, consisting of numbers from 1 to n, inclusive. Le…
D. Little Elephant and Array time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant loves playing with arrays. He has array a, consisting of n positive integers, indexed from…
C. Little Elephant and Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array a of le…
A. Little Elephant and Function time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant enjoys recursive functions. This time he enjoys the sorting function. Let a is a permuta…
221B - Little Elephant and Numbers 思路: 水题: 代码: #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; ; ]; int main() { scanf("%d",&n); int pos=n; ) i…
二次联通门 : Codeforces 221d D. Little Elephant and Array /* Codeforces 221d D. Little Elephant and Array 题意 : 询问一段区间中出现次数等于自身的数的个数 正解是dp 莫队水过, 作为我莫队的入门题 myj的思路 66 把所有需查询的区间排序 当前查询区间的答案为上一个区间的答案通过多次的区间移动得出 */ #include <algorithm> #include <cstdio>…
题目链接: http://codeforces.com/problemset/problem/213/B B. Numbers time limit per test 2 secondsmemory limit per test 256 megabytes 问题描述 Furik loves writing all sorts of problems, especially such that he can't solve himself. You've got one of his proble…
D. Beautiful numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/problem/D Description Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only i…
A. Johny Likes Numbers 题目连接: http://www.codeforces.com/contest/678/problem/A Description Johny likes numbers n and k very much. Now Johny wants to find the smallest integer x greater than n, so it is divisible by the number k. Input The only line con…
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…
D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if…
题目链接:https://codeforces.com/contest/55/problem/D 题目大意:给你一段区间[l,r],要求这段区间中可以整除自己每一位(除0意外)上的数字的整数个数,例如15,因为15既可以整除1也可以整除5,所以15符合要求. (1 ≤ li ≤ ri ≤ 9 ·1018). Examples input Copy 11 9 output Copy 9 input Copy 112 15 output Copy 2 解题思路:很明显的数位dp,首先我们可以想一个数…
Codeforces 204 E 题意:给\(n\)个串,求对于每一个串在至少\(k\)个串中出现的它的子串\(S_{l..r}\)有多少个. 思路:后缀自动机上\(dp\)... 我们首先构造出这\(n\)个串的后缀自动机,其中需要注意将某个串的构建完了后直接将\(lst\)指针赋为\(root\),那么就可以包含这些串的所有子串并且不会有问题. 然后我们就考虑如何来算出某一个子串在\(n\)个串中出现了多少次. 假设现在我们从\(S_i\)的开头走到第\(j\)位,走到了节点\(u\),那么…
C. Really Big Numbers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks…
E  DZY Loves Fibonacci Numbers In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation F1 = 1; F2 = 1; Fn = Fn - 1 + Fn - 2 (n > 2). DZY loves Fibonacci numbers very much. Today DZY gives you an array consist…
C. Hexadecimal's Numbers time limit per test 1 second memory limit per test 64 megabytes input standard input output standard output One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got access to the me…
题目链接:http://codeforces.com/problemset/problem/914/C 题意: 对数字x进行一次操作,可以将数字x变为x在二进制下1的个数. 显然,一个正整数在进行了若干次操作后一定会变成1. 给定n,k(n用二进制表示给出,n <= 2^1000). 问你有多少不超过n的正整数,将它们变为1所需的操作次数恰好为k. 题解: 由于n <= 2^1000,所以任何不超过n的数在进行了一次操作后,一定不超过1000. 所以先统计出1000以内所有数变成1所需的操作次…
http://codeforces.com/contest/220/problem/B 题意:给出一个数组,给出m组询问,问区间中出现a[i] 次的有多少个. sl: 很显然的离线问题了. 大视野菜花的加强版. 可以这么搞,假设当前走到了a 看看之前是不是有a个a有的话就在a-k处 减1 同时补上上次的操作就行.具体键代码. http://codeforces.com/contest/220/submission/6948720…
题目描述: D. Vus the Cossack and Numbers Vus the Cossack has nn real numbers aiai. It is known that the sum of all numbers is equal to 00. He wants to choose a sequence bb the size of which is nn such that the sum of all numbers is 00 and each bibi is ei…
题目:http://codeforces.com/contest/1186/problem/D 题意:给定一个大小为$n$的浮点序列,这$n$个数的和为0. 现在对这个序列中的每个数,进行向上取整或向下取整的操作,使得得到的整数序列之和也是0. 思路:假设我们现在的某一种取法得到的和是$ans$,那么改变其中一个数的取法对$ans$的改变可能是+1或是-1 所以我们想随便按照某种方法得到一个结果,再进行调整就可以了. 最简单的就是我们全部先取整数部分,如果此时的$ans>0$说明负数都太小了,那…
链接: https://codeforces.com/contest/1209/problem/A 题意: You are given a sequence of integers a1,a2,-,an. You need to paint elements in colors, so that: If we consider any color, all elements of this color must be divisible by the minimal element of thi…
A 无trick水题... /* * Author: Plumrain * Created Time: 2013-12-24 22:26 * File Name: B.cpp */ #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cmath> #include <algorithm> #include <ve…
题目 传送门:QWQ 分析 很难想到方向,但有方向了就很easy了. 我们如何减少不必要的计算? 如果我们知道了$ 100111 $的相容的数,$ 100101 $的相容数和他是完全一样的. 我们就靠着这个思想写一下就行了. 注意位运算优先级. 代码 #include <bits/stdc++.h> using namespace std; <<, INF=(<<)-; int dp[maxn], a[maxn]; int main(){ int n; scanf(&q…
题意:长度为n的排列,m次交换xi, yi,每个交换x,y有50%的概率不发生,问逆序数的期望  .n, m <= 1000 思路:我们只用维护大小关系,dp[i][j]表示位置i的数比位置j的数大的概率. 那么每次交换x和y.  假设x<y,那么区间就有三种:  [1,x-1],[x+1,y-1], [y+1,N], 不难证明这三个区间和xy处的逆序对关系变为二者和的一半. #include<bits/stdc++.h> #define rep(i,a,b) for(int i=…
题目链接~~> 做题感悟:这题属于想法题,比赛时直接做的 D 题.可是处理坐标处理的头晕眼花的结果到最后也没AC. 解题思路: 由于查询的时候仅仅考虑素数,so~我们仅仅考虑素数就能够,这就须要筛素数.我们能够在筛素数的同一时候把某个素数出现的倍数加上.输入的时候仅仅要记录某个数的个数就能够了. 代码: #include<iostream> #include<sstream> #include<map> #include<cmath> #include…
题意:题目中定义了一种运算,把数字x变成数字x的二进制位数.问小于n的恰好k次运算可以变成1的数的个数(题目中的n是二进制数,n最大到2^1000) 思路:容易发现,无论多么大的数,只要进行了一次运算,一定会变成1000以内的数,所以我们可以预处理1000以内的数经过多少次运算到1.之后,我们可以枚举1000以内的数字,枚举有哪些数字是经过k - 1次运算到1(假设此时数字是i),那么小于n的位数为i的数字都是答案.怎么统计答案呢?我们用试填法.我们dfs中传入3个参数:deep(当前搜索到第几…
[链接] 我是链接,点我呀:) [题意] f[i]表示在x[]中有多少个数字是i的倍数 让你求出sum(f[i]) li<=i<=ri 且i是质数 [题解] 做筛法求素数的时候顺便把素数i在x[]中的倍数的个数求出来就好 前缀和 输出即可 [代码] import java.io.*; import java.util.*; public class Main { static InputReader in; static PrintWriter out; public static void…
Lucky Ticket Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 146A Description Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal…
A. Little Elephant and Function 逆推. B. Little Elephant and Numbers \(O(\sqrt n)\)枚举约数. C. Little Elephant and Problem 排序后对应不相等的位置为2,且两数交换. D. Little Elephant and Array 离线+分块. E. Little Elephant and Shifts 每个数单独考虑. 假设\(x\)在数组\(a\)的位置\(i\),在数组\(b\)的位置\…