zoukankan      html  css  js  c++  java
  • 2019高一期中考试 std代码

    之所以没有讲解,因为有原题,而且我都讲过了QwQ

    没有去掉超长的头文件还真是抱歉呢

    T1

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <algorithm>
    #include <string>
    #include <vector>
    #include <set>
    #include <queue>
    #include <stack>
    #include <map>
    using namespace std;
    #define go(i, j, n, k) for(int i = j; i <= n; i += k)
    #define fo(i, j, n, k) for(int i = j; i >= n; i -= k)
    #define rep(i, x) for(int i = h[x]; i != -1; i = e[i].nxt)
    #define curep(i, x) for(int i = cur[x]; i != -1; i = e[i].nxt)
    #define mn 1000100
    #define inf 1 << 30
    #define ll long long
    #define root 1, n, 1
    #define lson l, m, rt << 1
    #define rson m + 1, r, rt << 1 | 1
    #define bson l, r, rt
    #define mod 1000000007
    inline int read(){
        int x = 0, f = 1; char ch = getchar();
        while(ch > '9' || ch < '0') { if(ch == '-') f = -f; ch = getchar(); }
        while(ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
        return x * f;
    }
    
    ll f[mn], n; 
    
    inline void solve() {
        n = read();
        f[1] = 1, f[2] = 1, f[3] = 1;
        go(i, 4, n, 1)
            f[i] = (f[i - 1] + f[i - 3]) % mod;
        cout << f[n] << "
    ";
    }
    inline void init() {
    
    }
    int main(){
    //	while(1) {
    
            init();
            solve();
    //	}
        return 0;
    }
    
    

    T2

    #include <algorithm>
    #include <cmath>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <ctime>
    #include <iostream>
    #include <map>
    #include <queue>
    #include <set>
    #include <stack>
    #include <string>
    #include <vector>
    using namespace std;
    #define go(i, j, n, k) for (int i = j; i <= n; i += k)
    #define fo(i, j, n, k) for (int i = j; i >= n; i -= k)
    #define rep(i, x) for (int i = h[x]; i; i = e[i].nxt)
    #define mn 1000010
    #define inf 2147483647
    #define ll long long
    #define ld long double
    #define fi first
    #define se second
    #define root 1, n, 1
    #define lson l, m, rt << 1
    #define rson m + 1, r, rt << 1 | 1
    #define bson l, r, rt
    //#define LOCAL
    #define mod 
    #define Debug(...) fprintf(stderr, __VA_ARGS__)
    inline ll read(){
        ll f = 1, x = 0;char ch = getchar();
        while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
        while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
        return x * f;
    }
    //This is AC head above...
    int n, d[mn];
    ll m, a[mn], ans;
    
    int main(){
        n = read(), m = read();
        go(i, 1, n, 1) {
            a[i] = read(), d[i] = read();
        }
        go(i, 1, n, 1) {
            if(d[i])
                ans = max(ans, m + 1 - a[i]);
            else
                ans = max(ans, a[i]);
        }
        cout << ans << "
    ";
    #ifdef LOCAL
        Debug("
    My Time: %.3lfms
    ", (double)clock() / CLOCKS_PER_SEC);
    #endif
        return 0;
    }
    

    P.S. : T2注意 long long

    T3

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <algorithm>
    #include <string>
    #include <vector>
    #include <set>
    #include <queue>
    #include <stack>
    #include <map>
    using namespace std;
    #define go(i, j, n, k) for(int i = j; i <= n; i += k)
    #define fo(i, j, n, k) for(int i = j; i >= n; i -= k)
    #define rep(i, x) for(int i = h[x]; i; i = e[i].nxt)
    #define mn 101000
    #define mm 1010
    #define inf 1 << 30
    #define ll long long
    #define root 1, n, 1
    #define lson l, m, rt << 1
    #define rson m + 1, r, rt << 1 | 1
    #define bson l, r, rt
    inline int read(){
        int x = 0, f = 1; char ch = getchar();
        while(ch > '9' || ch < '0') { if(ch == '-') f = -f; ch = getchar(); }
        while(ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
        return x * f;
    }
    
    int a[mn], b[mn], c[mn], n, m; // b鏄�€嶆暟锛宑鏄�綑鏁?
    int hnx[mm][mm];
    
    inline int get_ans(int l, int r, int B, int now) {
    //	go(i, l, r, 1) 
    //		go(j, 0, B, 1)
    //			hnx[i][j] = 0;
        go(i, l, r, 1) b[i] = a[i];
        go(i, l, r, 1) c[i] = b[i] % B;
        go(i, l, r, 1) b[i] /= B;
        go(i, l, r, 1) {
            hnx[c[i]][b[i]] = now;
        }
        int ans = 0;
        go(i, 0, B, 1) {
            int j = 0;
            while(hnx[i][j] == now) ++j;
            ans = max(ans, j);
        }
        return ans;
    }
    
    inline void solve() {
        n = read();
        go(i, 1, n, 1) a[i] = read();
        m = read();
        go(i, 1, m, 1) {
            int l = read(), r = read(), B = read();
            int ans = get_ans(l, r, B, i);
            printf("%d
    ", ans);
        } 
    }
    inline void init() {
    
    }
    int main(){
    //	while(1) {
    
            init();
            solve();
    //	}
        return 0;
    }
    
    

    T4

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <algorithm>
    #include <string>
    #include <vector>
    #include <set>
    #include <queue>
    #include <stack>
    #include <map>
    using namespace std;
    #define go(i, j, n, k) for(int i = j; i <= n; i += k)
    #define fo(i, j, n, k) for(int i = j; i >= n; i -= k)
    #define rep(i, x) for(int i = h[x]; i != -1; i = e[i].nxt)
    #define curep(i, x) for(int i = cur[x]; i != -1; i = e[i].nxt)
    #define mn 1000010
    #define inf 1 << 30
    #define ll long long
    #define root 1, n, 1
    #define lson l, m, rt << 1
    #define rson m + 1, r, rt << 1 | 1
    #define bson l, r, rt
    #define mod 19260817
    inline int read(){
        int x = 0, f = 1; char ch = getchar();
        while(ch > '9' || ch < '0') { if(ch == '-') f = -f; ch = getchar(); }
        while(ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
        return x * f;
    }
    
    ll ba[mn], f[mn];
    int T, n[mn], maxx; 
    
    inline void solve() {
        T = read();
        go(i, 1, T, 1) 
            n[i] = read(),
            maxx = max(maxx, n[i]);
        f[0] = 0, f[1] = 0, f[2] = 1;
        go(i, 3, maxx, 1) 
            f[i] = ((i - 1) * ((f[i - 1] + f[i - 2]) % mod)) % mod;
        go(i, 1, T, 1)
            printf("%lld
    ", f[n[i]]);
    }
    inline void init() {
    
    }
    int main(){
    //	while(1) {
    
            init();
            solve();
    //	}
        return 0;
    }
    
    

    非常水是不是

  • 相关阅读:
    数据库基础
    (转)数据流图
    (转)SQL执行顺序
    (转)数据库隔离级别及实现原理
    (转)求单链表是否有环,环入口和环长
    (转)最长公共子序列
    (转)Java锁、自旋锁、CAS机制
    Java线程状态转换
    OpenSUSE 13.2安装Texlive2014+Texmaker+Lyx
    GIMP也疯狂之动态图的制作(四)
  • 原文地址:https://www.cnblogs.com/yizimi/p/10854318.html
Copyright © 2011-2022 走看看