随笔分类 -  ACM--规律、技巧题

摘要:链接去年南京邀请赛的水题,当时找规律过的,看它长得很像数位dp,试了试用数位dp能不能过,d出每位上有多少个1,然后TLE了。。然后用规律优化了前4位,勉强过了。附数位dp代码及找规律代码。 1 #include 2 #include 3 #include 4 #include 5 #i... 阅读全文
posted @ 2014-06-22 18:10 _雨 阅读(193) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4671这个高端的题意啊 看了N久啊n>m时 直接第一列按顺序来 第二列为M+1else 第一列顺序来 第二列 按第一组为N 第二组为N-1 依次分配 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define N 110 8 int f[110][110],a[110][110],x[110]; 9 int main()10 {11 int i,j,k,n,m;12 while... 阅读全文
posted @ 2013-08-14 10:39 _雨 阅读(199) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4655先以最大的来算为 N*所有的排列数 再减掉重复的 重复的计算方法:取相邻的两个数的最小值再与它前面的组合数和后面的组合数相乘注意负值 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define LL long long 8 #define N 1000100 9 #define mod 100000000710 LL s1[N],s2[N],a[N],b[N];11 int main(). 阅读全文
posted @ 2013-08-09 10:30 _雨 阅读(175) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4639统计连续he的数量恰为斐波序列 不同块进行相乘 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define mod 10007 7 using namespace std; 8 char ss[11000]; 9 int f[11000];10 int main()11 {12 int t,i,k,kk=0;13 cin>>t;14 f[1] = 1;f[2] = 2;15 for(i = 3; i ... 阅读全文
posted @ 2013-08-04 12:38 _雨 阅读(177) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4642这题。。刚一看以为是什么高深的博弈 后来看过的人挺多 想是不是有什么规律 结果理解错题意了 以为随便圈一矩形改变就可以 然后想了一方法 跟QC说 然后就知道自己理解错题意了 必须圈到右下角 然后就乱了 后来QC说感觉只要右下角是1她就赢了 一想确实是这样啊 。。好简单 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int a[110][110]; 7 int main() 8 { 9 int i,j,t... 阅读全文
posted @ 2013-08-02 09:50 _雨 阅读(191) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4282仔细想这个题的时候 不到一小时了 开始写的时候也就还剩半个小时了 实验室开始很乱 打的也很乱 交了几次CE WA TLE之后 就放弃了也是一道水题 了z为2时是完全平方 z从3开始枚举View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 #include<math.h> 5 using namespace std; 6 __int64 pows(int x,int 阅读全文
posted @ 2012-09-10 19:58 _雨 阅读(209) 评论(0) 推荐(0) 编辑
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2383一下午卡死在这道题上了 还错了那么多次 郁闷最后经cz提醒 用求出的循环节对每个字母的循环节取余 算每个位置该输出什么字母View Code 1 #include<stdio.h> 2 #include<string.h> 3 #define LL long long 4 char str[100],ss[10][101]; 5 LL gcd(LL a, LL b) 6 { 7 return b==0?a:gcd( 阅读全文
posted @ 2012-08-29 18:01 _雨 阅读(182) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4377写了一下午也没找出规律 还剩十几分钟的时候CZ看出了规律 这时候再找正确的字典序已经晚了,,官方解题报告: 其实这是个挺有趣的题,你需要构造一个 1..N 的排列,使得其最长上升序列的长度和最长下降序列的长度的最大值最小。应该比较容易能够想到这个答案是 sqrt(N) 级别的,这个结论的证明可以参考吴文虎的那本组合数学 p21 。 当然这还没有结束,怎么找字典序最小的那个解呢?先看看完全平方数吧,对于 4 ,我们有 2 1 4 3 ,对于 9 ,我们有 3 2 1 6 5 4 9 8 7 。嗯... 阅读全文
posted @ 2012-08-16 22:32 _雨 阅读(240) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionI have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.InputThe first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers 阅读全文
posted @ 2012-02-17 21:09 _雨 阅读(199) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionThe digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the process is repeated. This is cont 阅读全文
posted @ 2012-02-16 23:17 _雨 阅读(346) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示