zoukankan      html  css  js  c++  java
  • HDU 中的数学题目

    //Made by syx
    //Time : 2010年8月14日 16:20:34

    //
    //

    //1071 The area
    //可令抛物线表达式为y= a(x-x1)^2+y1;
    //直线表达式为y=kx+b;
    //面积可通过微积分来计算a(x-x1)^2+y1 -(kx+b)在x2到x3区间内的定积分的值则为面积结果。

    #include <stdio.h>
    int main()
    {
    int n;
    scanf("%d",&n);
    while(n--)
    {
    double x0,y0,x1,y1,x2,y2,area=0;
    scanf("%lf %lf %lf %lf %lf %lf",&x0,&y0,&x1,&y1,&x2,&y2);
    area=(y0-y1)*(x2-x1)+(y2-y0)*(x2-x0)/3.0-(y1-y0)*(x1-x0)/3.0-(y2-y1)*(x2-x1)/2.0;
    printf("%.2lf\n",area);
    }
    return 0;
    }

    /*
    //1205 吃糖果
    //只要最大的那份比剩下的所有的多2个就no

    //

    #include <iostream>
    using namespace std;

    int main()
    {
    int t;
    scanf("%d",&t);
    while (t--)
    {
    int a,n;
    __int64 max=0,sum=0;
    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
    scanf("%d",&a);
    sum += a;
    if (max<a)
    max = a;
    }
    if (max > sum-max+1)
    printf("No\n");
    else printf("Yes\n");
    }
    return 0;
    }

    */
    /*
    //1021 Fibonacci Again
    //可以找到规律从第3个开始 每4个循环!
    //no no | yes no no no | yes no no no

    #include <stdio.h>

    int main()
    {
    int n;
    while(scanf("%d", &n) !=EOF)
    {
    if((n-2)%4) // 根据上述规律
    printf("no\n");
    else
    printf("yes\n");
    }
    return 0;
    }

    */
    /*
    //1021

    #include <stdio.h>
    __int64 f[1000000];
    int main()
    {
    f[0] = 7;
    f[1] = 11;

    int i , n;

    for(i=2; i<100000; i++)
    f[i] = f[i-1] + f[i-2];
    while(scanf("%d",&n) != EOF)
    {
    if(f[n]%3)
    printf("no\n");
    else
    printf("yes\n");
    }
    return 0;
    }

    */

    /*
    //1425 sort

    //快速排序搞定
    #include <stdio.h>
    #include <stdlib.h>


    int a[1000000];
    int cmp(const void *a, const void *b)
    {
    return *(int*)a - *(int *)b;
    }
    int main()
    {
    int n,m, i;
    //int *a = new int[1000000];
    while(scanf("%d%d",&n,&m) != EOF )
    {
    for(i=0; i<n; i++)
    {
    scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),cmp);
    for(i=n-1; i>=(n-m); i--)
    {
    printf("%d",a[i]);
    if(i != (n-m) )
    printf(" ");
    }
    printf("\n");
    }
    return 0;
    }

    */

    /*
    //1061 Rightmost Digit
    //求N^N
    //可以找到规律 :0的任何次方都是0 , 1的都是2 ,2的是 2 4 6 8 、、、
    //我们可以打表,当然也可以找到这是循环的中的第几次!直接小规模的计算!AC

    #include <stdio.h>
    int main()
    {
    //int a[10][4] = {{0,0,0,0},{1,1,1,1},{2,4,8,6},
    {3,9,7,1},{4,6,4,6},{5,5,5,5},
    {6,6,6,6},{7,9,3,1},{8,4,2,6},
    {9,1,9,1}};
    int n,num,temp,i,result,t;
    scanf("%d",&n);
    while(n--)
    {
    scanf("%d",&num);
    temp = num % 10;
    t = num %4;
    if(!t)
    t=4;
    result = 1;
    for(i=0; i<t; i++)
    {
    result = result * temp;
    result %= 10;
    }
    printf("%d\n",result);

    }
    return 0;
    }

    */
    /*

    //1061 test
    //可以获得 0 -9 i^i 的值 发现规律
    #include <stdio.h>
    void print(int m)
    {
    int result =1 , i;
    for(i=1; i<=9; i++)
    {
    result *= m;
    result %= 10;
    printf("%2d",result);
    }
    printf("\n");
    }
    int main()
    {
    for(int i=0; i<10; i++)
    {
    print(i);
    }
    return 0;
    }

    */
    /*

    //1061
    //num 大绝对超时
    #include <stdio.h>
    int main()
    {
    int n,num,temp,i,result;
    scanf("%d",&n);
    while(n--)
    {
    scanf("%d",&num);
    temp = num % 10;
    result = 1;
    for(i=0; i<num; i++)
    {
    result = result * temp;
    result %= 10;
    }
    printf("%d\n",result);

    }
    return 0;
    }

    */
    /*

    //1108 最小公倍数
    //记得那个 **公式!
    #include <stdio.h>
    int gcd(int da,int xiao)
    {
    int temp;
    while (xiao!=0)
    {
    temp=da%xiao;
    da=xiao;
    xiao=temp;
    }
    return(da);
    }
    int lcm(int m,int n)
    {
    //return m / gcd(m,n) * n;
    return m *n / gcd(m,n);
    }
    int main()
    {
    int m,n;
    while(scanf("%d%d",&m,&n) != EOF)
    {
    printf("%d\n",lcm(m,n));
    }
    return 0;
    }

    */

    /*

    //1008 Elevator
    //题目理解起来很有难度!
    //别人的AC代码
    //理解起来很那个啊!
    #include <stdio.h>

    int main()
    {
    int n , total , next , pro ;

    while( scanf( "%d" , &n ) , n )
    {
    pro = 0 ;
    total = 0 ;
    while( n -- )
    {
    scanf( "%d" , &next ) ;
    if( next > pro )
    total += ( next - pro ) * 6 + 5 ;
    else
    total += ( pro - next ) * 4 + 5 ;
    pro = next ;
    }
    printf("%d\n" , total ) ;
    }
    return 0 ;
    }

    */

    作者:BuildNewApp
    出处:http://syxchina.cnblogs.comBuildNewApp.com
    本文版权归作者、博客园和百度空间共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则作者会诅咒你的。
    如果您阅读了我的文章并觉得有价值请点击此处,谢谢您的肯定1。
  • 相关阅读:
    MVC3 Razor模板引擎
    Razor引擎学习:RenderBody,RenderPage和RenderSection
    Lambda表达式详解
    MVC的重定向页面的跳转
    dataSet==>Ilist<>的函数封装
    shell 判断目录还是文件
    大写金额转小写(千万以下)
    python将有序列表转乱序,模拟音乐播放器随机播放列表
    ssh登录远程linux服务器的错误
    ubuntu Unable to locate package错误解决办法
  • 原文地址:https://www.cnblogs.com/syxchina/p/2197375.html
Copyright © 2011-2022 走看看