9 条题解

  • 7
    @ 2022-3-26 16:00:01

    实际上就两种大体做法:

    1. 使用各大语言的 method 来代替运算符出现
    2. 使用列表的求和或者长度方法来乱搞

    具体实现各显神通

    你真写位运算就输了

    Python

    import operator
    
    a, b = map(int, input().split())
    print("{} {} {}".format(operator.add(a, b),
          operator.sub(a, b), operator.mul(a, b)))
    

    C++

    #include <functional>
    #include <iostream>
    
    using namespace std;
    
    int main() {
        std::ios::sync_with_stdio(false);
    
        int a, b;
        std::cin >> a >> b;
        std::cout << plus<>{}(a, b) << ' ' << minus<>{}(a, b) << ' ' << multiplies<>{}(a, b) << '\n';
    
        return 0;
    }
    
    #include <functional>
    #include <iostream>
    #include <valarray>
    
    using namespace std;
    
    int main() {
        std::ios::sync_with_stdio(false);
    
        int a, b;
        std::cin >> a >> b;
        std::cout << std::valarray<int>{a,b}.sum() << ' ' 
                  << std::valarray<int>{a,std::negate<>{}(b)}.sum() << ' '
                  << std::valarray<int>(a,b).sum() << '\n'; 
    
        return 0;
    }
    

    信息

    ID
    246
    时间
    1000ms
    内存
    256MiB
    难度
    2
    标签
    (无)
    递交数
    209
    已通过
    45
    上传者