Bestcoder Round 84 解题+补题记录

## 题目链接:
### [A.Aaronson](http://acm.hdu.edu.cn/showproblem.php?pid=5747)
### [B.Bellovin](http://acm.hdu.edu.cn/showproblem.php?pid=5748)
### [C.Colmerauer](http://acm.hdu.edu.cn/showproblem.php?pid=5749)
### [D.Dertouzos](http://acm.hdu.edu.cn/showproblem.php?pid=5750)

## A
### 题意:

### 思路:

### Code:
```
#include <iostream>
#include <string>
using namespace std;
long long list[35];
void init() {
    list[0] = 1;
    for (int i = 1; i <= 31; ++i) {
        list[i] = list[i - 1] * 2;
    }
}
int main() {
ios::sync_with_stdio(0);
    int kase;
    cin >> kase;
    init();
    for (int i = 0; i < kase; ++i) {
        long long n, m;
        cin >> n >> m;
        if (m >= 30) m = 30;
        if (list[m + 1] > n) {
            long long ans = 0;
            while (n != 0) {
                if (n & 1) ans++;
                n /= 2;
            }
            // cout << "?" << endl;
            cout << ans << endl;
        } else {
            long long ans = 0;
            while (n != 0) {
                ans += n / list[m];
                n = n % list[m];
                m--;
            }
            // cout << " ?? " << endl;
            cout << ans << endl;
        }
    }
    return 0;
}
```
## B
### 题意:
### 思路:
### Code:
```
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int kase;
    cin >> kase;
    while (kase--) {
        int n;
        cin >> n;
        vector<int> nums;
        vector<int> ans;
        for (int i = 0; i < n; ++i) {
            int tem;
            cin >> tem;
            nums.push_back(tem);
        }
        const int maxn = n;
        int min[maxn];
        int dp[maxn];
        int len = 0;
        for (int i = 0; i < n; ++i) {
            int pos = lower_bound(ans.begin(), ans.end(), nums[i]) - ans.begin();
            dp[i] = pos + 1;
            if (pos >= ans.size()) {
                ans.push_back(nums[i]);
            } else
                ans[pos] = nums[i];
            len = max(pos + 1, len);
            // dp[i] = len;
        }
        for (int i = 0; i < n - 1; ++i) {
            cout << dp[i] << " ";
        }
        cout << dp[n - 1];
        cout << endl;
    }
    return 0;
}
```
## C
### 题意:
### 思路:
### Code:

## D
### 题意:
### 思路:
### Code:
剩下的先占坑

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值