zoukankan      html  css  js  c++  java
  • Codeforces Round #614 (Div. 2)B(JOE is on TV!)

    B - JOE is on TV!

    题目链接:http://codeforces.com/contest/1293/problem/B

    思路:这题没咋看题,,,直接看了底下注释说是1/2+1/1,再看了两个样例,把数据往调和函数里一代就对了,,,直接暴力for循环求就行了

    // 
    // Created by HJYL on 2020/1/13.
    //
    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    #include<queue>
    #include<cmath>
    #define eps 1e-8
    #define Inf 0x7fffffff
    //#include<bits/stdc++.h>
    using namespace std;
    const int maxn=1e5+100;
    struct Point{
        double x,y;
    };
    double min(double a, double b) { return a < b ? a : b; }
    
    double max(double a, double b) { return a > b ? a : b; }
    
    bool IsSegmentIntersect(Point a, Point b, Point c, Point d)
    {
        if( min(a.x, b.x) > max(c.x, d.x) ||
            min(a.y, b.y) > max(c.y, d.y) ||
            min(c.x, d.x) > max(a.x, b.x) ||
            min(c.y, d.y) > max(a.y, b.y) )
            return 0;
    
        double h, i, j, k;
    
        h = (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
        i = (b.x - a.x) * (d.y - a.y) - (b.y - a.y) * (d.x - a.x);
        j = (d.x - c.x) * (a.y - c.y) - (d.y - c.y) * (a.x - c.x);
        k = (d.x - c.x) * (b.y - c.y) - (d.y - c.y) * (b.x - c.x);
    
        return h * i <= eps && j * k <= eps;
    }
    
    int main()
    {
        int T;
        scanf("%d",&T);
        if(T==1)
            printf("1.000000000000
    ");
        else
        {
            double sum=0.0;
            for(int i=1;i<=T;i++)
            {
                sum+=(1.0)/(i*1.0);
            }
            printf("%.12lf
    ",sum);
        }
        return 0;
    }
  • 相关阅读:
    造轮子杂记2
    Net分布式系统之五:微服务架构
    C#设计模式:责任链模式
    NET Core1.0之CentOS平台开发控制台程序DEMO
    WCF Routing 服务
    设计模式之外观模式
    设计模式之简单工厂模式
    Eclipse快捷键总结
    Spring容器的初始化流程
    IOC容器的创建
  • 原文地址:https://www.cnblogs.com/Vampire6/p/12217787.html
Copyright © 2011-2022 走看看