uvalive 3708 Graveyard
2013-09-12 16:45
302 查看
解题思路:把每个雕塑移动到离他最近的位置
/////////////////////////////////////////////////////////////////////////// //problem_id: uvalive 3708 //user_id: SCNU20102200088 /////////////////////////////////////////////////////////////////////////// #include <algorithm> #include <iostream> #include <iterator> #include <iomanip> #include <cstring> #include <cstdlib> #include <string> #include <vector> #include <cstdio> #include <cctype> #include <cmath> #include <queue> #include <stack> #include <list> #include <set> #include <map> using namespace std; /////////////////////////////////////////////////////////////////////////// #pragma comment(linker,"/STACK:1024000000,1024000000") #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// const double EPS=1e-8; const double PI=acos(-1.0); const int x4[]={-1,0,1,0}; const int y4[]={0,1,0,-1}; const int x8[]={-1,-1,0,1,1,1,0,-1}; const int y8[]={0,1,1,1,0,-1,-1,-1}; /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// typedef long long LL; typedef int T; T max(T a,T b){ return a>b? a:b; } T min(T a,T b){ return a<b? a:b; } T gcd(T a,T b){ return b==0? a:gcd(b,a%b); } T lcm(T a,T b){ return a/gcd(a,b)*b; } /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// //Add Code: /////////////////////////////////////////////////////////////////////////// int main(){ /////////////////////////////////////////////////////////////////////// //Add Code: int n,m,i; while(scanf("%d%d",&n,&m)!=EOF){ double ans=0; for(i=1;i<n;i++){ double pos=(double)i/n*(n+m); ans+=fabs(pos-floor(pos+0.5))/(n+m); } printf("%.4lf\n",ans*10000); } /////////////////////////////////////////////////////////////////////// return 0; } /////////////////////////////////////////////////////////////////////////// /* Testcase: Input: 2 1 2 3 3 1 10 10 Output: 1666.6667 1000.0 1666.6667 0.0 */ ///////////////////////////////////////////////////////////////////////////
相关文章推荐
- 指南第一章 例题4 UVALive 3708 Graveyard(参考系)
- Graveyard UVALive - 3708(思维)
- UVALive - 3708 Graveyard
- 例题1.4 Graveyard UVALive - 3708 数学思维题
- UVAlive 3708 Graveyard(最优化问题)
- 思维 UVALive 3708 Graveyard
- UVALive 3708_Graveyard
- UVALive 3708 Graveyard
- UVALive 3708 Graveyard
- Graveyard UVALive - 3708(思维)
- UVAlive3708 UVA1388 POJ3154 Graveyard【水题】
- UVA 3708 Graveyard(思维)
- uva 3708 - Graveyard
- uvalive 3708 墓地雕塑
- UVA-3708-Graveyard
- UVA 3708 [Graveyard]
- UVALive 4875
- UVaLive5031 Graph and Queries(时光倒流+名次树)
- uva 1388 - Graveyard(数论)
- UVALive 6867 Plane Ticket Pricing