zoukankan      html  css  js  c++  java
  • 2020-10-30 — 补题报告

    https://codeforces.com/problemset/problem/743/A

    题意:给一个01字符串,指定两个位置,如果这两个位置的字符相等,则输出0,不相等则输出1

    #include <bits/stdc++.h>
    
    using namespace std;
    const int N = 100010;
    
    template <typename T>
    inline void read(T &s) {
        s = 0;
        T w = 1, ch = getchar();
        while (!isdigit(ch)) { if (ch == '-') w = -1; ch = getchar(); }
        while (isdigit(ch))  { s = (s << 1) + (s << 3) + (ch ^ 48); ch = getchar(); }
        s *= w;
    }
    struct node{
        int x, y;
    };
    
    bool cmp(node a, node b){
        return a.x < b.x;
    }
    int n, a, b;
    char str[N];
    int main()
    {
        cin >> n >> a >> b;
        scanf("%s", str + 1);
        
        if(str[a] == str[b])
            puts("0");
        else
            puts("1");
            
    } 

    https://codeforces.com/problemset/problem/743/B

    题意:给出数字规模和规律,找出第k个数是多少。

    可以递归着做,有点像是二分,比赛的时候忘记开long long 了...

    #include <bits/stdc++.h>
    
    using namespace std;
    const int N = 100010;
    typedef long long ll;
    template <typename T>
    
    inline void read(T &s) {
        s = 0;
        T w = 1, ch = getchar();
        while (!isdigit(ch)) { if (ch == '-') w = -1; ch = getchar(); }
        while (isdigit(ch))  { s = (s << 1) + (s << 3) + (ch ^ 48); ch = getchar(); }
        s *= w;
    }
    struct node{
        int x, y;
    };
    
    bool cmp(node a, node b){
        return a.x < b.x;
    }
    ll n, k, sum = 0, res = 0;
    ll f(int n){
        if(n == 0) return 2 * n + 1;
        return 2 * f(n - 1) + 1;
    }
    
    ll solve(ll k){
        
        if(k == (sum + 1) / 2){
            return n;
        }
        
        n --;
        sum /= 2;
        
        if(k > sum + 1){
            k -= (sum + 1);
        }
        
        return solve(k);
    }
    
    int main()
    {
        cin >> n >> k;
        sum = f(n - 1);    
        res = solve(k);
        cout << res << endl;
    }

    https://codeforces.com/problemset/problem/743/C

    题意 : 找出三个数 满足 2 / x = 1 / a   +  1 / b  +  1 / c;

    构造 假设 x = n,  a = n + 1, b = n * (n + 1), c = n

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main()
    {
        int n;
        cin >> n;
        n == 1 ? puts("-1") : printf("%d %d %d
    ", n + 1, n * (n + 1), n);
        
    }
  • 相关阅读:
    闭包
    关于this
    插件开发(对象级)
    IFC
    flex.css
    js移动端滑动事件
    Android 手机下输入框获取焦点时, 输入法挡住输入框的 bug
    vue 组件化spreadjs预览excel
    feign 熔断工厂 fallbackFactory的简单实现
    bat脚本批量启动程序
  • 原文地址:https://www.cnblogs.com/DefineWaAc/p/13944106.html
Copyright © 2011-2022 走看看