02 2014 档案
摘要:Let's assume thatv(n)is the largest prime number, that does not exceedn;u(n)is the smallest prime number strictly greater thann.Find.InputThe first line contains integert(1 ≤ t ≤ 500)— the number of testscases.Each of the followingtlines of the input contains integern(2 ≤ n ≤ 109).OutputPrinttli
阅读全文
摘要:C. On Number of Decompositions into Multiplierstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integermas a product of integersa1, a2, ...an. Your task is to find the number of distinct decompositions of numberminto the product of
阅读全文
摘要:题目描述撸呀撸很迷茫,因为他的左手总是不受控制,做一些不雅的事情。于是撸呀撸一狠心,决定戒撸。没想到,他的左手受不了寂寞,一闲下来就在键盘上各种乱敲。唔,神奇的左手表示,safasfasaafafsfafasffsfsfsffsfddfafdfsfadffafadfafadfadfafadfsfa……他发现敲出来的字符串有一定规律:如果将字符串划分成若干部分,那么每部分都可由其子串重复若干次得到。“若干次”往往大于1,但也可以为1。小撸想请你算一算:用最优的方法划分字符串,然后将各部分替换成其最短的连续重复子串,得到的字符串的最小长度是多少?输入格式一行字符,都是英文小写字母。输出格式一个正整
阅读全文
摘要:hdu 3336题意:输入一个字符串求每个前缀在串中出现的次数和sol:只要稍微理解下next 数组的含义就知道只要把每个有意义的next值得个数加起来即可PS:网上有dp解法orz,dp[i]表示以i为前缀串结尾的前缀串的总和,方程很容易写出//字符串上KMP(水)//从前向后扫,失配函数的位置就...
阅读全文
摘要:It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can write down all the non-empty prefixes of this string. For example:s: "abab"The prefixes are: "a", "ab", "aba", "abab"For each
阅读全文
摘要:做codeforces以来题目最水的一次A题:Fox and Number Game题意:就是用一堆数字来回减,直到减到最小值为止,再把所有最小值加,求这个值sol: 简单数论题目,直接求所有数字的最大公约数即可ps: 以前cf出过这道题目啊,出题人没救了 5分钟300人过1#include2#include3#include4usingnamespacestd;5constintMAX=1000;6intnum[MAX];7intgcd(inta,intb)8{9returnb==0?a:gcd(b,a%b);10}11intmain()12{13intn;14while(scanf(&qu
阅读全文
摘要:题意:支持增删,查操作,最后的序列式递增的。做法:主要是如何维护mod5的sum值,这里左儿子可以不用管,关键是右儿子的处理,可以假设右儿子有t个节点,左儿子有cnt个节点,则令(t+cnt)MOD 5= i 则tmod5=(i-cnt MOD 5)MOD 5 ,所以剩下的就是维护每个节点的节点总数以及相应的和就好了。1#include2#include3#include4typedeflonglongll;5usingnamespacestd;6#definelzu>1;21build(lz);build(rz);22}23}24voidadd(intu,intl,intr,intx,
阅读全文