Codeforces 414B Mashmokh and ACM】的更多相关文章

http://codeforces.com/problemset/problem/414/B 题目大意: 题意:一个序列B1,B2...Bl如果是好的,必须满足Bi | Bi + 1(a | b 代表a整除b), 求长度为K,元素大小小于等于N的序列个数 思路:f[i][j] 代表在序列的第i位,当前数字为j的方案数 #include<cstdio> #include<cmath> #include<algorithm> #include<cstring>…
题意:给你n和k,然后找出b1, b2, ..., bl(1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n),并且对所有的bi+1%bi==0,问有多少这样的序列? 思路:dp[i][j] 表示长度为i,以j为结尾有多少.dp[i][j]+=dp[i-1][s],j%s==0; #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ; int n,k; ][];…
$dp$. 记$dp[i][j]$表示已经放了$i$个数字,并且第$i$个数字放了$j$的方案数.那么$dp[i][j] = \sum\limits_{k|j}^{}  {dp[i - 1][k]}$.答案为$\sum\limits_{k=1}^{m}  {dp[n][k]}$ #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #i…
题意: 给你两个数n和k.求满足以下条件的数列有多少个. 这个数列的长度是k: b[1], b[2], ……, b[k]. 并且 b[1] <= b[2] <= …… <= b[k] <= n: 而且,前一个数能被后一个数整除. 思路: 用dp[i][j]表示长度为i,最后一个数是j的序列有多少种.然后递推就可以了. 代码: #include <cstdio> #include <cstring> #include <algorithm> usi…
题目链接: B. Mashmokh and ACM time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participat…
[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…
                                             B. Mashmokh and ACM                                                                                             time limit per test 1 second                                                                …
http://codeforces.com/problemset/problem/414/B B. Mashmokh and ACM time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh d…
codeforces 414D Mashmokh and Water Tanks 题意 题解 \(a_i\):第 \(i\) 层的结点个数. \(b_i\):第 \(i\) 层初始有水的结点个数. 如果不允许关闭水塔,最后的答案就是 \(max\{a_i\}\). 现在允许关闭部分水塔,我们可以把一些连续层数的水汇聚到同一层.假设我们汇聚 \([l, r]\) 范围的水,总花费是 \(\Sigma_{i=l}^r\{b_i*(r-i)\}\). 双指针实现即可. 代码 #include<bits…
大意: 给定n结点树, 有k桶水, p块钱, 初始可以任选不超过k个点(不能选根结点), 在每个点放一桶水, 然后开始游戏. 游戏每一轮开始时, 可以任选若干个节点关闭, 花费为关闭结点储存水的数量和, 然后未关闭的非根结点上的水会流入父结点, 然后再开始新的一轮. 当所有非根结点无水后游戏结束, 假设第$i$轮流入根节点的水为$w_i$, 游戏共进行了$l$轮, 求$max(w_1,w_2,...,w_l)$ 可以发现最优时一定是一段深度相邻的水, 所以双指针维护一段连续的区间就行了. 考虑每…
A. ACM ICPC time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as po…
题意:给你2^n个数,每次操作将其分成2^k份,对于每一份内部的数进行翻转,每次操作完后输出操作后的2^n个数的逆序数. 解法:2^n个数,可以联想到建立一棵二叉树的东西,比如  2,1,4,3就可以建成下面这样 [2,1,4,3]                        level 2 /               \ [2,1]              [4,3]                  level 1 /        \              /     \ [2…
题意:给你n和k,然后让你找出n个数使得gcd(a1,a2)+gcd(a3,a4)+......的和等于k: 思路:如果n为奇数,让前n-3个数的相邻两个数都为1,n-2和n-1两个数gcd为k-ans:ans为前n-3个数的和.为偶数的话,让前n-2个数的相邻两个数都为1,n和n-1两个数gcd为k-ans: #include <cstdio> #include <cmath> #include <cstring> #include <vector> #i…
这个题真的是超级超级水啊,哈哈哈哈哈哈.不要被题面吓到,emnnn,就这样... 代码: 1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include<algorithm> 5 using namespace std; 6 int main(){ 7 int n,m; 8 int t; 9 scanf("%d",&t); 10 while(t--){…
思路: dp. 实现: 1.O(n5/2) #include <iostream> #include <cstdio> using namespace std; ; ][]; int solve() { ; i <= n; i++) dp[][i] = ; ; i < k; i++) { ; j <= n; j++) { ; p * p <= j; p++) { ) { dp[i][j] = (dp[i][j] + dp[i - ][p]) % MOD; ]…
题目链接 附上代码: #include<cstdio> #include<cstring> #include<bits/stdc++.h> #define mod 1000000007 int n, k; // dp[len][last] ][]; int main(void) { while(~scanf("%d %d",&n,&k)){ memset(dp,,sizeof(dp)); ; i <= n; i++) dp[][…
目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一棵 n 个点的树,每个点的儿子是有序的. 现给定 m 次操作,每次操作是下列三种中的一种: (1)给定 u, v,询问 u, v 之间的距离. (2)给定 v, h,断开 v 到父亲的边,将 v 这棵子树加入到它的第 h 个祖先的最后一个儿子. (3)给定 k,询问在当前这棵树上 dfs 后得到 dfs 序中,最后一个深度为 k 的点的编号. Input…
点我看题目 A. Mashmokh and Lights time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputoutput:standard output Mashmokh works in a factory. At the end of each day he must turn off all of the lights. The lights on the factory a…
, b2, ..., bl (1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n) is called good if each number divides (without a remainder) by the next number in the sequence. More formally  for all i (1 ≤ i ≤ l - 1). Given n and k find the number of good sequences of length k. As the a…
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tas…
题目链接: C. Mashmokh and Reverse Operation time limit per test 4 seconds memory limit per test 512 megabytes input standard input output standard output Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university…
CodeForces 140A New Year Table Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u  Description Gerald is setting the New Year table. The table has the form of a circle; its radius equals R. Gerald invited many guests and is…
A. Mashmokh and Lights time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mashmokh works in a factory. At the end of each day he must turn off all of the lights. The lights on the factory are…
B - B Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 478B Description n participants of the competition were split into m teams in some manner so that each team has at least one partici…
A. ACM ICPCtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, b…
题目链接:http://www.codeforces.com/problemset/problem/509/A题意:f[i][1]=f[1][i]=1,f[i][j]=f[i-1][j]+f[i][j-1],求f[n][n].C++代码: #include <iostream> using namespace std; ][]; int main() { cin >> n; ;i<=n;i++) f[i][] = f[][i] = ; ; i <= n; i ++) ;…
E. Pretty Song time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output When Sasha was studying in the seventh grade, he started listening to music a lot. In order to evaluate which songs he likes m…
大一生活真 特么 ”丰富多彩“ ,多彩到我要忙到哭泣,身为班长,很多班级的事情需要管理,也是,什么东西都得体验学一学,从学生会主席.团委团总支.社团社长都体验过一番了,现在差个班长也没试过,就来体验了一番哈哈哈,其实这种精心服务一个班级的人还是很棒的一种感觉呢.思考思考最近的任务啊: (1)英语剧 (2)三下乡公益策划 (3)兼职 - 影视剧组后期特效 (3)三月底程序设计大赛天梯赛 (4)班会以及班级细节事件处理 (5)多模态视频处理 (6)兼职 - 校方艺考航拍记录 (7)六月四级考试和三下…
http://codeforces.com/contest/676 在allzysyz学弟和hqwhqwhq的邀请下,打了我的第三场CF... 毕竟在半夜..所以本来想水到12点就去睡觉的...结果一下次过了三题,发现第四题是个bfs,就打到了12:30....BC貌似是没有了,不知道后面还会不会有,最近就打CF为主吧.. A题: http://codeforces.com/problemset/problem/676/A 应该算是比较水吧.没有什么坑点.直接枚举最大值在最左最右侧和最小值在最左…
题目链接:http://codeforces.com/problemset/problem/590/A 题目大意是给一个串,头和尾每次变换保持不变. 中间的a[i]变成a[i-1],a[i],a[i+1]的中位数,而且此题串是01串. 对于01串 0 0 0中位数是0 0 0 1中位数是0 0 1 1中位数是1 1 1 1中位数是1 所以 1.串中有两个相邻以上的0或者1是保持不变的. 2.会变的只有是两个1中间的0或者两个0中间的1. 但是到这里的话,虽然证明了肯定能变成稳定态,就算把相同数字…