文章分类 - 数学
摘要:A simple problemTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2730Accepted Submission(s): 958Problem DescriptionZty很痴迷数学问题.。一天,yifenfei出了个数学题想难倒他,让他回答1 / n。但Zty却回答不了^_^. 请大家编程帮助他.Input第一行整数T,表示测试组数。后面T行,每行一个整数 n (113 #include14 int main(void) 15
阅读全文
摘要:Card CollectorTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1881 Accepted Submission(s): 872Special JudgeProblem DescriptionIn your childhood, do you crazy for collecting the beautiful cards in the snacks? They said that, for example, if y...
阅读全文
摘要://0MS 240K 1273 B C++ //简单数学题,计算圆形和矩形是否有交点//我是利用圆形 圆心式 判断 #include#includeint main(void){ int t; double x,y,r,x1,y1,x2,y2; scanf("%d",&t); while(t--) { scanf("%lf%lf%lf%lf%lf%lf%lf",&x,&y,&r,&x1,&y1,&x2,&y2); if(x1>x2){ double t1=x1;x1=x2;x2=t1;
阅读全文
摘要://0MS 228K 633 B C++ //多个数乘积的数根,与分别计算出数根再相乘计算数根答案一样 //一开始二了很久,一直多乘一次,杯具 O(logn) #includeint root(int a){ while(a%10!=a){ int ans=0; while(a){ ans+=a%10; a/=10; } a=ans; } return a;}int main(void){ int n; while(scanf("%...
阅读全文
摘要://15MS 248K 601 B C++ //读不懂题意是硬伤啊...//以输入的中间那个点为中点分成四个象限,再统计 #includestruct node{ int x,y;}v[200005];int main(void){ int x,y,n; while(scanf("%d",&n),n) { for(int i=0;i0&&v[i].y>0 || v[i].x<0&&v[i].y<0) cntx++; else cnty++; } prin...
阅读全文
摘要://0MS 228K 325 B C++//数学规律题,公式如下// f[n]=f[2]*f[n-2]+2*(f[n-4]+f[n-6]+...+f[2]+f[0])//-->f[n]=4*f[n-2]-f[n-4]#includeint main(void){ int n; int a[31]={1,0,3,0}; for(int i=4;i<31;i+=2) a[i]=4*a[i-2]-a[i-4]; while(scanf("%d",&n),n!=-1) { printf("%d\n",a[n]); }...
阅读全文
摘要://31MS 240K 799 B C++ //数学,平面薄板面积公式 #includestruct node{ double x,y;};double Area(node a,node b,node c) //三点面积公式 { return ((b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y))/2;}int main() { int t,n; double a,b; scanf("%d",&t); while(t--) { double sum_area=0; doub...
阅读全文
摘要:/* 分成最接近的两段。 证明如下: 设n为总长度,分为两段,长度分别为a、b。总次数=a*(a-1)/2+b*(b-1)/2=a*(a-1)/2+(n-a)*(n-a-1)/2=(2*a^2-2*n*a+n^2)/2。 其中n为常量,a为变量。二次曲线开口向上,最小值对应的a=-(-2*n)/(2*2)=n/2。显然a要求整数。*///15MS 228K 281 B C++ //开始没思路,看别人的结题报告,化成线性问题来接//分成最接近的两段做类似冒泡的移动 #includeint main(void){ int n; while(scanf("...
阅读全文
摘要://31MS 236K 715 B C++ //数学题,注意斜着放的情况 #include#includebool deal(double a,double b,double x,double y){ if(a>x && b>y) return true; if(a*b a) return false; return true;}int main(void){ double a,b,x,y; int t; scanf("%d",&t); while(t--) { scanf("%lf%lf%lf%lf",&a,
阅读全文
摘要:摘自:http://blog.sina.com.cn/s/blog_59e67e2c0100a7yx.html需要慢慢注墨。。。。首先引用下leemars的报告:这道题要求N!的最后一个非0数字是多少,如果用一般作法,先统计2和5的个数,然后补乘2,得到的将是TLE。所以还需要再做简化:为了把0去掉,我们把所有的因数2和5都提出来,放到最后再处理。N!中的N个相乘的数可以分成两堆:奇数和偶数。偶数相乘可以写成(2^M)*(M!),M=N DIV 2。M!可以递归处理,因此现在只需讨论奇数相乘。考虑1*3*5*7*9*11*13*15*17* ... *N(如果N为偶数则是N-1),这里面是5的
阅读全文
摘要:// 做了好一会儿,数学// 将 n^n 转化为 10^(n*lg(n)),其中 // n*lg(n)的小数部分作为10的幂为个位数 #include#includeint main(void){ __int64 t; double n; scanf("%I64d",&t); while(t--) { scanf("%lf",&n); double temp=n*log10(n),t0; double a=modf(temp,&t0); //a为temp的小数部分,t0为整数部分 a=pow(10.0,a...
阅读全文
摘要://数学题,推理,64位#includeint main(void){ __int64 a[21][21]={0}; int n,m; for(int i=1;i<21;i++) a[i][1]=i; for(int i=2;i<21;i++) for(int j=2;j<=i;j++) if(i==j) a[i][j]=a[i][j-1]; else a[i][j]=a[i][j-1]+a[i-1][j]; while(scanf("%d%d",&n,&m)!=EOF) { ...
阅读全文