运维开发网

所向披靡的响应式开发

运维开发网 https://www.qedev.com 2021-02-09 09:40 出处:51CTO 作者:mb60197fa41eb9f
download:所向披靡的响应式开发做一套多端适配的互联网金融响应式网页源于互联网金融真实案例以一个实际上线的互联网金融网页为案例,实际演示响应式网页的成型过程响应式开发所有知识包含了响应式开发所涉及到的几乎全部知识点,而且不仅限于开发,还涵盖了产品、设计、流程等方方面面,让你一次性将响应式开发学会对初学者非常友好讲师切实考虑到了初学者理解上的问题,每个知识点讲解都非常细致,只要你具备HTML、

download:所向披靡的响应式开发

做一套多端适配的互联网金融响应式网页

源于互联网金融真实案例

以一个实际上线的互联网金融网页为案例,实际演示响应式网页的成型过程

响应式开发所有知识

包含了响应式开发所涉及到的几乎全部知识点,而且不仅限于开发,还涵盖了产品、设计、流程等方方面面,让你一次性将响应式开发学会

对初学者非常友好

讲师切实考虑到了初学者理解上的问题,每个知识点讲解都非常细致,只要你具备HTML、CSS、JavaScript基础就可以学习本课程

良心价,良心课

学习人数和课程评价就是课程质量最好的证明,课程丰富的知识内容,相比别人家的课程,相信你会感受到慕课网的情怀

适合人群

只要你具备一定自学能力,了解HTML、CSS、JS基础知识,对响应式设计和开发有兴趣,就可以学习本课程

import java.io.OutputStream;

import java.io.IOException;

import java.io.InputStream;

import java.io.PrintWriter;

import java.util.SortedSet;

import java.util.Set;

import java.util.NavigableSet;

import java.io.IOException;

import java.io.InputStreamReader;

import java.util.TreeSet;

import java.util.ArrayList;

import java.util.List;

import java.util.StringTokenizer;

import java.io.BufferedReader;

import java.util.Comparator;

import java.util.Collections;

import java.io.InputStream;

/**

  • Built using CHelper plug-in
  • Actual solution is at the top

    */

    public class Main {

    public static void main(String[] args) {

    InputStream inputStream = System.in;

    OutputStream outputStream = System.out;

    InputReader in = new InputReader(inputStream);

    PrintWriter out = new PrintWriter(outputStream);

    TaskH solver = new TaskH();

    solver.solve(1, in, out);

    out.close();

    }

    static class TaskH {

    public void solve(int testNumber, InputReader in, PrintWriter out) {

    int n = in.nextInt();

    int len = in.nextInt();

    int[] x = new int[n];

    int[] y = new int[n];

    double[] s = new double[n];

    for (int i = 0; i < n; ++i) {

    x[i] = in.nextInt();

    y[i] = in.nextInt();

    s[i] = in.nextDouble();

    }

    List<TaskH.Segment> segments = new ArrayList<>();

    int pos = 0;

    for (int i = 0; i < n; ++i) {

    if (x[i] > pos) {

    segments.add(new TaskH.Segment(pos, x[i], 0.0));

    }

    segments.add(new TaskH.Segment(x[i], y[i], s[i]));

    pos = y[i];

    }

    if (pos < len) {

    segments.add(new TaskH.Segment(pos, len, 0.0));

    }

    out.println(solveOne(segments));

    }

    private double solveOne(List<TaskH.Segment> segments) {
        int n = segments.size();
        for (int i = 0; i < n; ++i) {
            TaskH.Segment s = segments.get(i);
            s.ptr = i;
            s.curEnergy = 0.0;
            s.maxEnergy = (s.right - s.left) / s.s;
            s.minEnergy = -(s.right - s.left) / (s.s + 2);
        }
        List<TaskH.Segment> segmentsByS = new ArrayList<>(segments);
        Collections.sort(segmentsByS, new Comparator<TaskH.Segment>() {
    
            public int compare(TaskH.Segment o1, TaskH.Segment o2) {
                int z = Double.compare(o2.s, o1.s);
                if (z == 0) {
                    z = Integer.compare(o2.left, o1.left);
                }
                return z;
            }
        });
        TreeSet<TaskH.Segment> available = new TreeSet<>(new Comparator<TaskH.Segment>() {
    
            public int compare(TaskH.Segment o1, TaskH.Segment o2) {
                return o1.ptr - o2.ptr;
            }
        });
        available.addAll(segments);
        for (TaskH.Segment s : segmentsByS) {
            if (s.s == 0.0) break;
            s.alive = false;
            available.remove(s);
            NavigableSet<TaskH.Segment> after = available.tailSet(s, false);
            double capacity = s.maxEnergy - s.curEnergy;
            double spent = 0.0;
            while (!after.isEmpty()) {
                TaskH.Segment t = after.first();
                if (t.alive) {
                    double t1 = t.curEnergy - t.minEnergy;
                    double t2 = capacity - spent;
                    double transfer = Math.min(t1, t2);
                    spent += transfer;
                    t.curEnergy -= transfer;
                    if (t1 <= t2) {
                        available.remove(t);
                    } else {
                        break;
                    }
                }
            }
            s.curEnergy += spent;
        }
        double res = 0.0;
        for (TaskH.Segment s : segments) {
            double v = (s.right - s.left - s.curEnergy * s.s) / (s.right - s.left + s.curEnergy);
            res += (s.right - s.left) / (s.s + v);
        }
        return res;
    }
    
    static class Segment {
        int left;
        int right;
        int ptr;
        double s;
        boolean alive = true;
        double minEnergy;
        double curEnergy;
        double maxEnergy;
    
        public Segment(int left, int right, double s) {
            this.left = left;
            this.right = right;
            this.s = s;
        }
    
    }

    }

    static class InputReader {

    public BufferedReader reader;

    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }
    
    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }

    }

扫码领视频副本.gif

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号