LA3708:Graveyard

来源:互联网 发布:java 替换换行符 编辑:程序博客网 时间:2024/05/01 15:07

地址:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=20&page=show_problem&problem=1709

这道题是看了大白书才写得出的,不得不说这思路真是碉堡了!

 

#include <stdio.h>#include <math.h>int main(){    int n,m;    while(~scanf("%d%d",&n,&m))    {        int i;        double t,ans = 0;        for(i = 1;i<=n;i++)        {            t = (double)i/n*(n+m);//计算需要移动的雕塑的坐标            ans+=fabs(t-floor(t+0.5))/(n+m);//累计移动距离        }        printf("%.4lf\n",ans*10000);    }    return 0;}

原创粉丝点击