zoukankan      html  css  js  c++  java
  • Codeforces Round #250 (Div. 2)

    感觉不会再爱了,呜呜!

    A题原来HACK这么多!很多人跟我一样掉坑了!

    • If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great.
    • If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice).

    pasting注意条件只能满足一个

    B:我能说我40分钟的时候想到正解吗?WOCAO,运算符的优先级搞蒙了!

    坑爆了:

    我的代码:#include<stdio.h>

    #include<string>
    #include<algorithm>
    #include<math.h>
    #include<vector>
    #include<set>
    #include<map>
    #include<string.h>
    #include<iostream>

    using namespace std;
    int a[200000];
    int b[200000];
    int m,n;
    int main()
    {
        cin>>n>>m;
        int t=0;
        for (int i=m;i>=1;i--)
        {
            if ((i&(-i))<=n)//满满的泪。。。。呜呜之前的版本是if (i&(-i)<=n)
            {
                t++;
                a[t]=i;
                n-=(i&-i);
            }
        }
        //cout<<n<<endl;
        if (n) cout<<-1;
        else
        {
            cout<<t<<endl;
            for (int i=1;i<=t;i++) cout<<a[i]<<" ";
        }
        return 0;

    } 原来&的优先级很低的,晕死!

    简要证明,不知道对不对

    I从limits 一直减小,每次加到SUM-lowbit(i);这样可以保证set的元素不同,然后,因为sum不断减小,当sum==0是既有满足答案。

    C:最水,难怪出题人说DIV2很好玩! 

  • 相关阅读:
    [Swift] Swift3.0--GCD
    [Android Pro] Swift 3.0多线程
    [MAC OS ] UserDefaults
    [MAC OS] NSOpenPanel 使用
    [ IOS ] iOS-控制器View的创建和生命周期
    [ IOS ] 视图控制对象ViewController的生命周期
    [Android Pro] AtomicInteger的用法
    [MAC OS] 常用工具
    [MAC OS] NSButton tag 获取
    [MAC OS] XCode中的Debug View Hierarchy功能
  • 原文地址:https://www.cnblogs.com/forgot93/p/3763947.html
Copyright © 2011-2022 走看看