• hdu多校6


    这个场要恶心死我了。。

    1001

    积分题,不要四舍五入

    //#pragma comment(linker, "/stack:200000000")
    //#pragma GCC optimize("Ofast,no-stack-protector")
    //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    //#pragma GCC optimize("unroll-loops")
    #include<bits/stdc++.h>
    #define fi first
    #define se second
    #define db double
    #define mp make_pair
    #define pb push_back
    #define pi acos(-1.0)
    #define ll long long
    #define vi vector<int>
    #define mod 1000000007
    #define ld long double
    #define C 0.5772156649
    #define ls l,m,rt<<1
    #define rs m+1,r,rt<<1|1
    #define pll pair<ll,ll>
    #define pil pair<int,ll>
    #define pli pair<ll,int>
    #define pii pair<int,int>
    //#define cd complex<double>
    #define ull unsigned long long
    #define base 1000000000000000000
    #define Max(a,b) ((a)>(b)?(a):(b))
    #define Min(a,b) ((a)<(b)?(a):(b))
    #define fio ios::sync_with_stdio(false);cin.tie(0)
    template<typename T>
    inline T const& MAX(T const &a,T const &b){return a>b?a:b;}
    template<typename T>
    inline T const& MIN(T const &a,T const &b){return a<b?a:b;}
    inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
    inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
    inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
    inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
    inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c,b>>=1;}return ans;}
    
    using namespace std;
    
    const double eps=1e-8;
    const ll INF=0x3f3f3f3f3f3f3f3f;
    const int N=100000+10,maxn=400000+10,inf=0x3f3f3f3f;
    
    int a,b;
    int main()
    {
        int T;scanf("%d",&T);
        while(T--)
        {
            scanf("%d%d",&a,&b);
            double ans=pi*a+2.0*b;
            ll ret = ans * 1000000;
            printf("%.6f
    ", 1.0 * ret / 1000000);
        }
        return 0;
    }
    /********************
    
    ********************/
    View Code

    1012

    物理题。。。。

    #include<bits/stdc++.h>
    using namespace std;
    const int N = 300;
    const int mod = 1000000007;
    double a, b, x, y;
    int main() {
        int T; scanf("%d", &T);
        while(T--) {
            scanf("%lf%lf%lf%lf", &a, &b, &x, &y);
            a=fabs(a);
            b=fabs(b);
            x=fabs(x);
            y=fabs(y);
            double h = x * (b) / a;
            double val = b / sqrt(a * a + b * b);//sin
    
            double H=y-h;
            double t=sqrt(2*9.8*H)/9.8;
    
            double hi=0;
            for(int i = 1;i <=100; i++) {
                hi+=4*i*9.8*t*t*val*val;
                if(hi>h){
                    printf("%d
    ",i);
                    break;
                }
            }
        }
    
    }
    View Code

    1009

    村民永远无法确定,狼只能在只有一条狼边的环里确认,然后找出这些狼反推找其他狼。

    #include<bits/stdc++.h>
    #define LL long long
    #define fi first
    #define se second
    #define mk make_pair
    #define PII pair<int, int>
    #define PLI pair<LL, int>
    #define PLL pair<LL, LL>
    #define y1 skldjfskldjg
    #define y2 skldfjsklejg
    
    using namespace std;
    
    const int N = 1e5 + 7;
    const int M = 1e5 + 7;
    const int inf = 0x3f3f3f3f;
    const LL INF = 0x3f3f3f3f3f3f3f3f;
    const int mod = 1e9 +7;
    const double PI = acos(-1);
    const double eps = 1e-7;
    
    int to[N], n, a[N];
    bool vis[N], is[N];
    char s[100];
    
    vector<int> edge[N];
    int deg[N];
    int main() {
        int T; scanf("%d",&T);
        while(T--){
            memset(vis, 0, sizeof(vis));
            memset(deg, 0, sizeof(deg));
            memset(is, 0, sizeof(is));
            queue<int> que, Q;
            scanf("%d",&n);
            for(int i = 1; i <= n; i++) edge[i].clear();
            for(int i = 1; i <= n; i++) {
                scanf("%d%s", &to[i], s);
                if(s[0] == 'w') {
                    a[i] = 1;
                } else {
                    a[i] = 0;
                    edge[to[i]].push_back(i);
                }
                deg[to[i]]++;
            }
    
            for(int i = 1; i <= n; i++) {
                if(!deg[i]) {
                    is[i] = true;
                    Q.push(i);
                }
            }
    
            while(!Q.empty()) {
                int u = Q.front(); Q.pop();
                int v = to[u];
                if(is[v]) continue;
                deg[v]--;
                if(!deg[v]) {
                    Q.push(v);
                    is[v] = true;
                }
            }
    
            for(int i = 1; i <= n; i++) {
                if(is[i]) continue;
                int id = -1, cnt = 0, now = i;
                while(!is[now]) {
                    is[now] = true;
                    if(a[now]) cnt++, id = to[now];
                    now = to[now];
                }
                if(cnt == 1) {
                    vis[id] = true;
                    que.push(id);
                }
            }
    
            while(!que.empty()) {
                int u = que.front(); que.pop();
                for(int i = 0; i < edge[u].size(); i++) {
                    int v = edge[u][i];
                    if(vis[v]) continue;
                    vis[v] = true;
                    que.push(v);
                }
            }
    
            int ans = 0;
            for(int i = 1; i <= n; i++)
                if(vis[i]) ans++;
            printf("0 %d
    ", ans);
        }
        return 0;
    }
    /*
    */
    View Code

    补题****************************************************************************************

    1002

    我们首先要找出这两个性质。。。

    gcd(2 ^ a - 1, 2 ^ b - 1) = gcd(2 ^ (gcd(a, b)) - 1)

    gcd(fib[ i ], fib[ j ]) = f [gcd(i , j)]

    http://bestcoder.hdu.edu.cn/blog/

    题解说的很清楚啦

    #include<bits/stdc++.h>
    #define LL long long
    #define fi first
    #define se second
    #define mk make_pair
    #define pii pair<int, int>
    #define y1 skldjfskldjg
    #define y2 skldfjsklejg
    
    using namespace std;
    
    const int N = 1e6 + 7;
    const int M = 1e5 + 7;
    const int inf = 0x3f3f3f3f;
    const LL INF = 0x3f3f3f3f3f3f3f3f;
    const int mod = 1e9 +7;
    
    int inv[N << 1], f[N << 1], finv[N << 1], fib[N], bin[N], stk[N], a[N], n, k, tot;
    
    int fastPow(int a, int b) {
        int ans = 1;
        while(b) {
            if(b & 1) ans = 1ll * ans * a % mod;
            a = 1ll * a * a % mod; b >>= 1;
        }
        return ans;
    }
    
    void add(int &a, int b) {
        a += b; if(a >= mod) a -= mod;
    }
    void sub(int &a, int b) {
        a -= b; if(a < 0) a += mod;
    }
    
    void init() {
        finv[0] = f[0] = inv[1] = f[1] = finv[1] = fib[1] = 1;
        for(int i = 2; i < N * 2; i++) {
            inv[i] = 1ll * (mod - (mod / i)) * inv[mod % i] % mod;
        }
        for(int i = 2; i < N * 2; i++) {
            f[i] = 1ll * f[i - 1] * i % mod;
            finv[i] = 1ll * finv[i - 1] * inv[i] % mod;
        }
        for(int i = 2; i < N; i++) fib[i] = (fib[i - 1] + fib[i - 2]) % (mod - 1);
    }
    
    int comb(int n, int m) {
        return 1ll * f[n] * finv[m] % mod * finv[n - m] % mod;
    }
    
    int main() {
        init();
        int T; scanf("%d", &T);
        while(T--) {
            memset(a, 0, sizeof(a)); tot = 0;
            scanf("%d%d", &n, &k);
    
            int ans = 0;
            for(int i = n; i >= 1; i--) {
                if(n % i) continue;
                a[i] = comb(n / i + k - 1, k - 1);
                for(int j = i + i; j <= n; j += i)
                    sub(a[i], a[j]);
                add(ans, 1ll * a[i] * (((fastPow(2, fib[i]) - 1 + mod) % mod)) % mod);
            }
            ans = 1ll * ans * fastPow(comb(n + k - 1, k - 1), mod - 2) % mod;
            printf("%d
    ", ans);
        }
        return 0;
    }
    View Code

    1004

    区间dp,先把线段的两个端点用极坐标离散化一下,总共只有2*n个发射方向。

    dp[ i ][ j ]表示把完全位于i, j之间的线段都射穿需要的代价,对于一个区间来说

    然后枚举最大需要的能量发射的方向之后变成两个独立区间然后转移。

    #include<bits/stdc++.h>
    #define LL long long
    #define fi first
    #define se second
    #define mk make_pair
    #define pii pair<int, int>
    #define y1 skldjfskldjg
    #define y2 skldfjsklejg
    
    using namespace std;
    
    const int N = 600 + 7;
    const int M = 1e5 + 7;
    const int inf = 0x3f3f3f3f;
    const LL INF = 0x3f3f3f3f3f3f3f3f;
    const int mod = 1e9 +7;
    
    int n, tot;
    LL f[N][N];
    struct Point {
        LL x, y;
        Point(LL x = 0, LL y = 0) : x(x), y(y) { }
    } hs[N];
    LL cross(const Point &a, const Point &b) {
        return a.x * b.y - a.y * b.x;
    }
    bool operator < (const Point &A, const Point &B) {return cross(A, B) < 0;}
    bool operator == (const Point &A, const Point &B) {return cross(A, B) == 0;}
    struct Line {
        Point L, R;
        int w, l, r;
    } a[N];
    LL dp(int i, int j) {
        if(i >= j) return 0;
        if(f[i][j] != -1) return f[i][j];
        int mx = -1;
        for(int k = 1; k <= n; k++)
            if(a[k].l >= i && a[k].r <= j && a[k].w > mx)
                mx = a[k].w;
        if(mx == -1) return f[i][j] = 0;
        f[i][j] = INF;
        for(int k = i; k <= j; k++) f[i][j] = min(f[i][j], dp(i, k - 1) + dp(k + 1, j) + mx);
        return f[i][j];
    }
    
    int main() {
        int T; scanf("%d", &T);
        while(T--) {
            memset(f, -1, sizeof(f)); tot = 0;
            scanf("%d", &n);
            for(int i = 1; i <= n; i++) {
                LL h, l, r, w;
                scanf("%lld%lld%lld%lld", &h, &l, &r, &w);
                a[i].L = Point(l, h); a[i].R = Point(r, h); a[i].w = w;
                hs[++tot] = a[i].L; hs[++tot] = a[i].R;
            }
            sort(hs + 1, hs + 1 + tot);
            tot = unique(hs + 1, hs + 1 + tot) - hs - 1;
            for(int i = 1; i <= n; i++) {
                a[i].l = lower_bound(hs + 1, hs + 1 + tot, a[i].L) - hs;
                a[i].r = lower_bound(hs + 1, hs + 1 + tot, a[i].R) - hs;
            }
            printf("%lld
    ", dp(1, tot));
        }
        return 0;
    }
    
    /*
    */
    View Code
  • 相关阅读:
    HDU-2222 Keywords Search(AC自动机)
    HDU-2647 Reward(拓扑排序)
    HDU-2896 病毒侵袭(AC自动机)
    UESTC-1057 秋实大哥与花(线段树+成段加减+区间求和)
    CSU-1120 病毒(最长递增公共子序列)
    记忆化搜索
    区间动态规划 矩阵连乘 Medium
    34枚金币时间管理法
    摄影基础1
    学习法则 讲
  • 原文地址:https://www.cnblogs.com/CJLHY/p/9452872.html
Copyright © 2020-2023  润新知