[链接]h在这里写链接 [题意] 在这里写题意 [题解] /* Be careful. 二重循环枚举 */ [错的次数] 0 [反思] 在这了写反思 [代码] #include <bits/stdc++.h> using namespace std; int n; string s[110]; int main() { //freopen("F:\\rush.txt", "r", stdin); scanf("%d", &n)…
[链接]h在这里写链接 [题意] 给你n个数字; 让你在其中找出三个数字i,j,k(i<=j<=k); 使得p*a[i]+q*a[j]+r*a[k]最大; [题解] /*     有一个要求i<=j<=k;     也就是说系数之间的下标是有关系的.     枚举第一个位置的下标i;         则第二个人j         i<=j<n         枚举中间那个人的位置在哪.     求出前i个位置,第一个人能获得的最大值是多少     求出后n-i个位置,第…
[链接]h在这里写链接 [题意]     k是最高级别的分数,最高界别的分数最多只能有x个.     1<=k<=m;     和k相邻的点的分数只能小于k;     n个点的树,问你每个点的分数的安排,方案数%1e9+7 [题解]     设     f[i][j][0];//这棵子树下面有j个最高级别的点,这个点放Top点的方案数     f[i][j][1];//这棵子树下面有j个最高级别的点,这个点放小于等于k-1的点的方案数     f[i][j][2];//这棵子树下面有j个最高级…
A. Tom Riddle's Diary time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Harry Potter is on a mission to destroy You-Know-Who's Horcruxes. The first Horcrux that he encountered in the Chamber…
E. Colored Balls time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n boxes with colored balls on the table. Colors are numbered from 1 to n. i-th box contains ai balls, all of which…
Time limit per test1 second memory limit per test 256 megabytes input standard input output standard output For a given positive integer n denote its k-rounding as the minimum positive integer x, such that x ends with k or more zeros in base 10 and i…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Leha somehow found an array consisting of n integers. Looking at it, he came up with a task. Two players play the game on the array. Players…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 如果我们对某一个位置i操作两次的话. 显然结果就和操作一次一样. 因为第一次操作过后1..i这些数字就变成是互质的了. gcd为1.那么除过之后没有影响的. 然后.就是要明白 那个f(x)函数的意义.其实就是问你x质因数分解之后,其中好的质数和坏的质数的差是多少. 也即有多少个好因数,多少个坏因数. (以下的gcd(i)都指的是a[1..i]这些数字的gcd 然后考虑我们在第i个位置进行了一次操作. 显然他会对后面的数字造成影响…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 做这题之前先要知道二叉排序树的一个性质. 就是它的中序遍历的结果就是这个数组升序排序. (且每个节点的左边的节点都是比这个节点的值小的,每个节点的右边的节点都是比这个节点的值大的. 则我们把原数组排序. 然后在这里面找到原来数组的a[1]的位置idx; 则1..idx-1这些数字都是a[1]的左子树. idx+1..n这些数字都是a[1]的右子树. 然后idx的左儿子是什么呢? 肯定就是1..idx-1中在原数组中最早出现的数字…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 题目的图吓人. 找下规律就会发现从内到外是1,6,12,18 即1,16,26,36... 即1+6(1+2+3+...) 等差求和公式. [代码] #include <bits/stdc++.h> #define ll long long using namespace std; ll n; int main() { ios::sync_with_stdio(0),cin.tie(0); #ifdef LOCAL_DEFIN…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 判断sum/2这个价值能不能得到就可以了. 则就是一个01背包模型了. 判断某个价值能否得到. f[j]表示价值j能否得到. f[0] = 1; 写个01背包就好 [代码] #include <bits/stdc++.h> #define ll long long using namespace std; const int M = 100*200; const int N = 100; int f[M+10],n,a[N+1…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 排序,逆序.贪心选较大的就好. [代码] #include <bits/stdc++.h> #define ll long long using namespace std; const int M =1e5; int f[M+10],a[1000+10],n,m; int main() { ios::sync_with_stdio(0),cin.tie(0); #ifdef LOCAL_DEFINE freopen(&quo…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 肯定是放在m-1或者m+1的. (m-1是左边的点都离a最近,而m+1则是右边的点都离他最近. 看看哪个更好就行 [代码] #include <bits/stdc++.h> #define ll long long using namespace std; ll n,m; int main() { ios::sync_with_stdio(0),cin.tie(0); #ifdef LOCAL_DEFINE freopen(&…
题目链接:http://codeforces.com/problemset/problem/676/B 题意:一个n层的平面酒杯金字塔,如图,每个杯子的容量相同.现在往最顶部的一个杯子倒 t 杯酒,求流动结束后有多少个杯子被装满. 思路:每个局部的两代三个杯子的流动过程是一致的,因此可以用递归来模拟求解. 具体为:设add(cur, i, l)执行“往第 i 个杯子倒cur量的酒”,附加信息: i 位于第 l 层.若执行完剩余了surplus量的酒,则往 i 的下一层左右两侧的杯子各倒surpl…
一.导出到Excel 1.使用DatabaseMetaData分析数据库的数据结构和相关信息. (1)测试得到所有数据库名: private static DataSource ds=DataSourceUtils_C3P0.getDataSource(); Connection conn=ds.getConnection(); DatabaseMetaData dbmd=conn.getMetaData(); ResultSet rs=dbmd.getCatalogs(); while(rs.…
一.dbutils的核心就是回调函数,可以说如果没有回调函数的思想,dbutils是不可能被开发出来的. 对于dbutils中的QuryRunner类,向该类的query方法提供不同的参数,可以得到不同类型的返回值类型,但是该方法并非是重载方法,这里借助回调函数和泛型可以实现和重载方法相同的效果,而且灵活性更高. 二.简单回调函数结构. 1.首先需要一个处理句柄的顶级接口,这是回调规范. interface RunnerHandler<T> { T handler(String str); }…
题目链接:http://codeforces.com/problemset/problem/633/G 大意是一棵树两种操作,第一种是某一节点子树所有值+v,第二种问子树中节点模m出现了多少种m以内的质数. 第一种操作非常熟悉了,把每个节点dfs过程中的pre和post做出来,对序列做线段树.维护取模也不是问题.第二种操作,可以利用bitset记录质数出现情况.所以整个线段树需要维护bitset的信息. 对于某一个bitset x,如果子树所有值需要加y,则x=(x<<y)|(x>>…
题目链接:http://codeforces.com/problemset/problem/633/C 大意就是给个字典和一个字符串,求一个用字典中的单词恰好构成字符串的匹配. 比赛的时候是用AC自动机写的,就是对于trie中每一个节点,判断是否为终结点,以及当前字符所在位置p减去trie中这个节点的深度也即某一单词的长度l,判断dp[p-l]是否可以被构成,可以的话直接break并且标记当前dp值. 赛后想了想,其实直接一个trie就行了,每个单词才1000的长度,又想起来我去年给人讲过类似的…
数学技巧真有趣,看出规律就很简单了 wa 题意:给出数k  输出所有阶乘尾数有k个0的数 这题来来回回看了两三遍, 想的方法总觉得会T 后来想想  阶乘 emmm  1*2*3*4*5*6*7*8*9*10...*n 尾数的0只与5有关 是5的几倍就有几个0  因为5前面肯定有偶数 乘起来就有一个0 而且最后输出肯定是连续的5个 hhh 兴奋 开始上手 乱搞一下  发现复杂度还行 测样例 发现 k=5 的时候不对了 输出25~29了 应该是0的 咦  测了一下 25!应该是6个0的 25=5*5…
还是dfs? 好像自己写的有锅 过不去 看了题解修改了才过qwq #include <cstdio> #include <algorithm> #include <cstring> #include <stack> #include <set> using namespace std; ],v[],n,m,k,ans; ],vis[]; ]; stack<int> S; void dfs(int u){ if(sons[u].size…
随便模拟下就过了qwq 然后忘了特判WA了QwQ #include <cstdio> #include <algorithm> #include <cstring> #include <set> #include <queue> using namespace std; ],v[],fir[],nxt[],cnt=,dep[],squ[]; ]; void addedge(int ui,int vi){ cnt++; u[cnt]=ui; v[c…
是一道水题 虽然看起来像是DP,但其实是贪心 扫一遍就A了 QwQ #include <cstdio> #include <algorithm> #include <cstring> #include <set> #include <map> using namespace std; ],b[],f[]; ],bx[]; int main(){ scanf("%d",&n); scanf(); scanf(); ;i&…
题目要求很简单,做法很粗暴 直接扫一遍即可 注意结果会爆int #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; ,n,s,a[]; int main(){ scanf("%I64d %I64d",&n,&s); ;i<=n;i++) scanf("%I64d&quo…
就是找一下规律 但是奈何昨天晚上脑子抽 推错了一项QwQ 然后重新一想 A掉了QwQ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; int main(){ int n; scanf("%d",&n); ,ans=,now=; while(i<n){ i+=now*; now*=;…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every the conditionai ≥ ai - 1 is me…
[CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/C 题面: C. Gerald's Hexagon time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Gerald got a very curious hexagon for his birthday. The bo…
[CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/B 题面: B. Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Gerald bought two very rare paintings at the Sotheby's a…
[CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/A 题面: A. Currency System in Geraldion time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A magic island Geraldion, where Gerald lives,…
[CF简单介绍] 提交链接:Two Buttons 题面: B. Two Buttons time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya has found a strange device. On the front panel of a device there are: a red button, a blu…
[CF简单介绍] 提交链接:A. Lala Land and Apple Trees 题面: A. Lala Land and Apple Trees time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Amr lives in Lala Land. Lala Land is a very beautiful country tha…