【30.49%】【codeforces 569A】Music】的更多相关文章

49 [程序 49 子串出现的个数] 题目:计算字符串中子串出现的次数 package cskaoyan; public class cskaoyan49 { public static void main(String[] args) { // TODO Auto-generated method stub java.util.Scanner in = new java.util.Scanner(System.in); System.out.println("请输入两个字符串,以回车隔开,母串…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Little Lesha loves listening to music via his smartphone. But the smartphone doesn't have much memory, so Lesha listens to his favorite songs in…
题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制数字,求出其长len,当len为奇数时,第一位为1,后面的位数如果都为0,则输出len,如果有一个不为0,则输出len+1: 当len为偶数时,则输出len.(之所以这样输出是因为题目给定4的次幂是从0开始的) #include<iostream> #include<string> #…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones. Once he thought ab…
time limit per test5 seconds memory limit per test512 megabytes inputstandard input outputstandard output This task is very simple. Given a string S of length n and q queries each query is on the format i j k which means sort the substring consisting…
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 test1 second memory limit per test256 megabytes inputstandard input outputstandard output Vanya has a scales for weighing loads and weights of masses w0,?w1,?w2,?-,?w100 grams where w is some integer not less than 2 (exactly one weight…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Ohana Matsumae is trying to clean a room, which is divided up into an n by n grid of squares. Each square is initially either clean or dirty. Oh…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output The tram in Berland goes along a straight line from the point 0 to the point s and back, passing 1 meter per t1 seconds in both directions. It me…
[题目链接]:http://codeforces.com/contest/776/problem/E [题意] f(n)是小于n的不同整数对(x,y)这里x+y==n且gcd(x,y)==1的个数; g(n)是n的所有因子的f值的和; 然后让你求一个递推式 [题解] x的欧拉函数为phi(x) 则f(n)=phi(n); 欧拉函数的定义是,小于这个值且与这个值互质的数的个数->phi(n); 可以证明每一个与n互质的数x对应了一个整数对(x,y)且x+y==n且gcd(x,y)==1; 然后有个…
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11674&courseid=0 题目大意: N个学生M道题(1<=N<=12,1<=M<=30),每道题只有正误两种选项(0 1),每个学生的答题情况和正确题数已知,求标准答案可能有多少种. 如果标准答案只有一种则输出标准答案,否则输出解的个数. 题目思路: […
[微信小程序项目实践总结]30分钟从陌生到熟悉 前言 我们之前对小程序做了基本学习: 1. 微信小程序开发07-列表页面怎么做 2. 微信小程序开发06-一个业务页面的完成 3. 微信小程序开发05-日历组件的实现 4. 微信小程序开发04-打造自己的UI库 5. 微信小程序开发03-这是一个组件 6. 微信小程序开发02-小程序基本介绍 7. 微信小程序开发01-小程序的执行流程是怎么样的? 阅读本文之前,如果大家想对小程序有更深入的了解,或者一些细节的了解可以先阅读上述文章,本文后面点需要对…
[题目链接]:http://codeforces.com/contest/761/problem/E [题意] 给你一棵树,让你在平面上选定n个坐标; 使得这棵树的连接关系以二维坐标的形式展现出来; [题解] dfs来搞; 显然如果某个点的度数大于4就无解. 初始坐标为(0,0)然后每一层的边的长度变为上一层长度的1/2 初始层的长度为2 30   这样可以保证每层节点都不会和上一层的相交; 因为2 i >2 1 +2 2 +...+2 i−1   又因为最多只有30个节点,所以这么做肯定是可以…
[题目链接]:http://codeforces.com/contest/767/problem/B [题意] 排队去办护照; 给你n个人何时来的信息; 然后问你应该何时去才能在队伍中等待的时间最短; (如果你和别人同时到,你要等到和你同时到的人全都办完了才轮到你); [题解] 细节题吧. 首先大体思路就是: 枚举那个人在哪个人办完之后办; 如果那个人办完之后和下一个时间的人之间有空隙->直接输出那个枚举的人办完后的时间->因为这表示等待时间为0的情况; 否则如果没有空隙,那么就要在下一个时间…
此文章转载地址:http://www.tuicool.com/articles/RJJvMj3 请注重作者的版权. spring-boot通过maven的依赖管理为我们写好了很多依赖项及其版本,我们可拿来使用.spring-boot文档介绍了两种使用方法,一是继承,二是导入. 通过<parent>继承: <project>   <parent>     <groupId>org.springframework.boot</groupId>    …
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output As you have noticed, there are lovely girls in Arpa's land. People in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th…
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket. The goods in the supermarket hav…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequ…
time limit per test2.5 seconds memory limit per test256 megabytes inputstandard input outputstandard output One tradition of welcoming the New Year is launching fireworks into the sky. Usually a launched firework flies vertically upward for some peri…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output There are n servers in a laboratory, each of them can perform tasks. Each server has a unique id - integer from 1 to n. It is known that during…
[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…
题目链接: http://codeforces.com/problemset/problem/691/D 题目大意: 给一个1到N的排列,M个操作(1<=N,M<=106),每个操作可以交换X Y位置上的数字,求可以得到的最大字典序的数列. 题目思路: [搜索][并查集] 这题可以用搜索或者并查集写,都能过. 把位置分成若干块,每一块里面的位置都是可以被这一块里另一个位置经过若干次调换的(类似强连通,位置可达). 然后把每一块位置里的 位置按从小到大排序,位置上的值按从大到小排序,依次填入位置…
题目链接: http://codeforces.com/problemset/problem/706/E 题目大意: 给一个N*M的矩阵,Q个操作,每次把两个同样大小的子矩阵交换,子矩阵左上角坐标分别为(a,b)和(c,d),高度h,宽度w. (2 ≤ n, m ≤ 1000, 1 ≤ q ≤ 10 000) 题目思路: [链表][模拟] 这一看如果直接模拟的话时间复杂度是N*M*Q,肯定T了. 把矩阵看成链表,链表的方向有上下左右四种,其实每次交换两个子矩阵只改变的外围一圈的链表值,而内部的链…
题目链接: http://codeforces.com/problemset/problem/710/D 题目大意: 两个等差数列a1x+b1和a2x+b2,求L到R区间内重叠的点有几个. 0 < a1, a2 ≤ 2·109,  - 2·109 ≤ b1, b2, L, R ≤ 2·109, L ≤ R). 题目思路: [数论][扩展欧几里得] 据题意可得同余方程组 x=b1(mod a1) 即 x=k1*a1+b1 x=b2(mod a2) x=k2*a2+b2 化简,k1*a1=k2*a2…
题目链接: http://codeforces.com/problemset/problem/710/E 题目大意: 问写N个字符的最小花费,写一个字符或者删除一个字符花费A,将当前的字符数量翻倍花费B. 题目思路: [动态规划][最短路] [动态规划]: 如果当前x不是2的倍数,那么一定需要单个字符增加或删除,而这个单个操作越靠后答案越优. dp(x)=a+min(dp(x-1),dp(x+1)) 如果当前x是2的倍数,那么有两种情况,一种是通过翻倍的方式获得,一种是通过累加的方式获得.只要比…
题目链接: http://codeforces.com/problemset/problem/707/D 题目大意: 一个N*M的书架,支持4种操作 1.把(x,y)变为有书. 2.把(x,y)变为没书. 3.把x行上的所有书状态改变,有变没,没变有. 4.回到第K个操作时的状态. 求每一次操作后书架上总共多少书. 题目思路: [离线][深搜][树] 现场有思路不过没敢写哈.还是太弱了. 总共只用保存一张图,把操作看成一棵树,一开始I操作连接在I-1操作后,如果遇到操作4的话,把I操作与I-1操…
题目链接: http://codeforces.com/problemset/problem/698/B http://codeforces.com/problemset/problem/699/D 题目大意: 通过给定当前节点的父亲给你一棵有错的树,可能有多个根和环,输出改成正确的一棵树至少要修改几个节点的父亲和修改后所有点的父亲值 题目思路: [并查集][模拟] 用并查集把成环的归在一起(类似强连通分量),然后统计分量数并修改. 第一个出现的当作根,其余的每一块连通分量都去掉一条边改为连接到…
题目链接: http://codeforces.com/problemset/problem/696/A 题目大意: 一个满二叉树,深度无限,节点顺序编号,k的儿子是k+k和k+k+1,一开始树上的边权都为0 N(N<=1000)个操作,操作两种,1是从u到v的路径上的所有边权+w,2是求u到v的边权和.(1 ≤ v, u ≤ 1018, v ≠ u, 1 ≤ w ≤ 109) 题目思路: [STL][模拟] 用map写很快,第一次用很生疏.现学只看了一点点. 因为是满二叉树所以直接暴力求LCA…
题目链接: http://codeforces.com/contest/706/problem/D 题目大意: 三种操作,1.添加一个数,2.删除一个数,3.查询现有数中与x异或最大值.(可重复) 题目思路: [字典树][贪心] 维护一个字典树,左0右1.查询时从上往下走. // //by coolxxx // #include<iostream> #include<algorithm> #include<string> #include<iomanip>…