随笔分类 -
乱搞题
HDU 4970
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4970比赛的时候线段树水过的,比赛后线段树一直T,看了下正解真的是智商压制题意:走直线,长度1-N,还有一些人,起点任意,每个人有血量,m个塔,每个塔有攻击范围和伤害,在一个点只会受到塔一次攻击,走到N存活,问存活...
阅读全文
HDU 3546
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3546题意:10个寄存器初值为1,有加乘赋值运算,最多30w次运算,大数最多5000位,问最后10个寄存器的结果题解:想直接暴力,但是会超时,30w*5000略多,关键优化是注意到如果出现赋值运算,则被赋值的寄存器...
阅读全文
三分
摘要:整数//三分极小值 int Left, Right;int mid, midmid;int mid_value, midmid_value;Left = minn; Right = maxn;while (Right - Left > 5){ mid = (Left + Right) / 2;...
阅读全文
HDU 2175
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2175做得好辛苦的一道规律题,至于为什么辛苦。。dont ask me why。。。n号盘子出现的位置是(1,3,5,7......)*2^(n-1)#include using namespace std ;typedef __int64 ll ;int main(){ ll a[105] ; a[1]=1 ; for(int i=2 ;i<64 ;i++) a[i]=a[i-1]*2 ; ll n,m ; while(~scanf("%I64d%I64d",&n...
阅读全文
两个二分
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4190二分答案#include using namespace std ;int a[500005] ;int main(){ int n,b ; while(~scanf("%d%d",&n,&b),n!=-1) { int maxn=-1 ; for(int i=0 ;i>1 ; int sum=0 ; for(int i=0 ;ib) left=mid+1 ; e...
阅读全文
HDU 2268
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2268小学四年级应用题,让我找回了儿时的快乐。。。#include #include #include using namespace std ;int main(){ int a,b,c ; while(~scanf("%d%d%d",&a,&b,&c)) { if(b<=a) { printf("%.3lf\n",c*1.0/a) ; continue ; } double x=c*1.0...
阅读全文
HDU 2199 Can you solve this equation?
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2199找到方程的解,直接二分,注意精度View Code #include <iostream>using namespace std ;const double eps=1e-8 ;double f(double x){ return 8*x*x*x*x+7*x*x*x+2*x*x+3*x+6 ;}int main(){ int t ; double mid ; scanf("%d",&t) ; while(t--) { double y ; ...
阅读全文
HDU 2407 Knots
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2407yy题View Code #include <iostream>using namespace std ;int main(){ int n ; while(~scanf("%d",&n)) { double ans=1 ; for(int i=n-1;i>=2;i-=2) ans*=(i-1)*1.0/i ; printf("%.5lf\n",ans) ; } return 0 ;}
阅读全文
HDU 1124 Factorial
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1124求n!末尾有多少个0,2*5出0,所以既求有多少个因子5View Code #include <iostream>using namespace std ;int main(){ int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); int ans=0; while(n) { n/=5; ans+=n; ...
阅读全文
HDU 2715 Herd Sums
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2715直接暴了。。。View Code #include <iostream>using namespace std ;int main(){ int n; while(~scanf("%d",&n)) { int ans=0,sum; for(int i=1;i<=n;i++) { sum=0; for(int j=i;j<=n;j++) { sum+=...
阅读全文
HDU 2800 Adding Edges
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2800View Code #include <iostream> using namespace std; int main(){ int n; while(scanf("%d",&n),n) printf("%d\n",(n+1)>>1); return 0;}
阅读全文
SRM 544 DIV 2 250
摘要:坑点:0特判View Code const double esp=1e-11;string ElectionFraudDiv2::IsFraudulent(vector <int> percentages) { vector <double> sb ; double sum=0; for (int i = 0 ; i < percentages.size() ; i++) { sum+=percentages[i]+0.0; sb.push_back(percentages[i]+0.0); } double sum1,sum2;...
阅读全文
HDU 1977 Consecutive sum II
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1977很容易看出规律View Code #include <stdio.h>#include <string.h>int main(){ int t; __int64 n; scanf("%d",&t); while(t--) { scanf("%I64d",&n); printf("%I64d %I64d\n",n*n*n,(n+1)*(n+1)*(n+1)); } return 0;}
阅读全文
HDU 1996 汉诺塔VI
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1996递推View Code #include <iostream>#include <string>using namespace std;int main(){ int t; __int64 dp[30]={0,3}; for(int i=2;i<30;i++) dp[i]=dp[i-1]*3; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); printf(&quo
阅读全文
HDU 1708 Fibonacci String
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1708不能直接用string加,最后的位数很多,会超内存。一定注意特殊处理k=0和k=1的情况。最后有空行View Code #include <iostream>#include <cstdlib>#include <cstring>#include <string>#include <stack>#include <queue>#include <map>#include <algorithm>using na
阅读全文
HDU 1273 漫步森林
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1273乱搞题,n-1减去起点,把剩下的点分成尽可能相等的两部分1、2(为了得到尽可能大的答案),对于1内部来讲,显然总能保证“新鲜”,在新鲜1后,不难看出2的每个点都对应着一个“新鲜”说的乱七八糟,大概就这样吧。。。View Code #include <iostream>#include <queue>#include <stack>#include <vector>using namespace std;int main(){ int n; while(sc
阅读全文
HDU 1280 前m大的数
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1280hash+最大堆,STL堆View Code #include <iostream>#include <map>#include <vector>#include <queue>#include <cstring>using namespace std;int hash[10001];int main(){ int n,m; priority_queue <int> q; while(~scanf("%d%d",
阅读全文
HDU 1060 Leftmost Digit
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1060脑筋急转弯。View Code #include <stdio.h>#include <math.h> int main(){ int t; double n; scanf("%d",&t); while(t--) { scanf("%lf",&n); printf("%d\n",(int)pow(10.0,n*log10(n)-(__int64)(n*log10(n)))); } return 0;}
阅读全文
HDU 1496 Equations
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1496今天刚知道这种方法叫哈希。。。开始没考虑清楚边界,各种错,A了再看也就那么回事View Code #include <stdio.h>#include <string.h>const int N=1000000;int hash[2000001];int main(){ int a,b,c,d; int ans; int i,j; while(~scanf("%d%d%d%d",&a,&b,&c,&d)) { if((a>
阅读全文
HDU 1492 The number of divisors(约数) about Humble Numbers
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1492计算约数的个数,由已知条件"A number whose only prime factors are 2,3,5 or 7 is called a humble number."简化运算。View Code #include <stdio.h>__int64 find(__int64 n,int a){ __int64 ans=0; while(1) { if(n==1)break; if(n%a==0) { ans++...
阅读全文
|
|