zoukankan      html  css  js  c++  java
  • C

    ceil有毒啊。。用ceil一直错。

    思路就是模拟吧,设当前的答案是ansx和ansy。

    如果比例是小于ansx的,那么就要乘以一个倍数k1,使得a * k1 >= ansx的。

    所以就用ceil(ansx / a)嘛。。然后一直wa。

    ansy的同理,最后选一个倍数大的去乘就行了。

    搞不清楚为什么用ceil会wa

    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <algorithm>
    using namespace std;
    #define inf (0x3f3f3f3f)
    typedef long long int LL;
    
    #include <iostream>
    #include <sstream>
    #include <vector>
    #include <set>
    #include <map>
    #include <queue>
    #include <string>
    
    void work() {
        int n;
        cin >> n;
        LL ansx = 1, ansy = 1;
        for (int i = 1; i <= n; ++i) {
            LL a, b;
            cin >> a >> b;
            LL k1 = 1;
            if (a < ansx) {
    //            k1 = max(k1, (LL)ceil(1.0 * ansx / a)); ceil有毒?
                k1 = ansx / a;
                if (ansx % a != 0) k1++;
            }
            if (b < ansy) {
    //            k1 = max(k1, (LL)ceil(1.0 * ansy / b));
                LL t = ansy / b;
                if (ansy % b != 0) t++;
                k1 = max(k1, t);
            }
            ansx = a * k1;
            ansy = b * k1;
        }
        cout << ansx + ansy << endl;
    }
    
    int main() {
    #ifdef local
        freopen("data.txt","r",stdin);
    #endif
        work();
        return 0;
    }
    View Code
  • 相关阅读:
    Dolby pro logic introduction
    3.8 Language Support(audio)
    what is dual mono
    会计misc
    除权除息
    MPEG2-TS音视频同步原理(PCR dts pts)
    计算视频文件(包含PCR)播放带宽的方法 PCR计算码率
    cocos2d 动作切换
    cocos2d 播放音乐
    cocos2d 主角更随触屏走
  • 原文地址:https://www.cnblogs.com/liuweimingcprogram/p/5965496.html
Copyright © 2011-2022 走看看