码迷,mamicode.com
首页 > 其他好文 > 详细

usaco Electric Fence

时间:2015-09-28 10:01:15      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:

这种有小数的题目总会令我格外头疼。

/*
ID: modengd1
PROG: fence9
LANG: C++
*/
#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <math.h>
using namespace std;
long long ans,x1,x2;
int n,m,p;
int main()
{
    freopen("fence9.in","r",stdin);
    freopen("fence9.out","w",stdout);
    scanf("%d%d%d",&n,&m,&p);
    ans=0;
    for(int i=1;i<m;i++)
    {
        x1=(double)n*i/m;
        x2=p-double(p-n)/m*i;
        if((p-n)*i%m==0)//(p-n)*i/m是整数
            x2--;
        ans+=x2-x1;
    }
    cout<<ans<<endl;
    return 0;
}

  

usaco Electric Fence

标签:

原文地址:http://www.cnblogs.com/modengdubai/p/4843305.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!