zoukankan      html  css  js  c++  java
  • 笔试编程---快手实习题目

    第一题 快速幂

    #include <bits/stdc++.h>
     
    using namespace std;
     
    typedef long long LL;
     
    LL dfs(LL x, LL y, LL N)
    {
        if (y == 0)
            return 1;
        LL ret = dfs(x, y / 2, N);
        if (y % 2 == 0)
            return ret * ret % N;
        return ret * ret * x % N;
    }
     
    int main()
    {
        LL x, y, N;
        cin >> x >> y >> N;
        cout << dfs(x, y, N) << endl;
        return 0;
    }
      
    

      第二题二分查找

    #include <bits/stdc++.h>
     
    using namespace std;
     
    int main()
    {
        int x;
        char c;
        vector<int> arr;
        while (true) {
            scanf("%d", &x);
            arr.push_back(x);
            if (getchar() == '
    ')
                break;
        }
        scanf("%d", &x);
        printf("%u
    ", lower_bound(arr.begin(), arr.end(), x) - arr.begin());
        return 0;
    }
    

      链接 来源于牛客网




  • 相关阅读:
    变量定义方法
    动态编译
    函数
    过程
    触发器
    高级聚合函数rollup(),cube(),grouping sets()
    高级函数-decode
    高级函数-sign
    js 保留两位小数 javascript
    js 发红包
  • 原文地址:https://www.cnblogs.com/gaochaochao/p/8893877.html
Copyright © 2011-2022 走看看