• UCF Local Programming Contest 2018


    A

    #include <bits/stdc++.h>
    using namespace std;
     
    int x, y, d;
     
    int main()
    {
         scanf("%d%d%d", &x, &y, &d);
         x -= d << 1;
         y -= d << 1;
         if (x <= 0 || y <= 0) printf("0");
         else printf("%d", x * y);
         return 0;
    }
    

      

    B

    #include <bits/stdc++.h>
    #define ull unsigned long long
    using namespace std;
    
    const int p = 131;
    const int maxn = 70000;
    
    int n;
    char s[25];
    vector<ull> ve[128];
    
    int main()
    {
        scanf("%d", &n);
        for (int i = 1; i <= n; ++i)
        {
            scanf("%s", s + 1);
            ull a = 0;
            for (int j = 1; s[j]; ++j) a = a * p + s[j];
            ve[s[1]].emplace_back(a);
        }
        long long ans = 0;
        for (int i = 0; i < 128; ++i)
        {
            sort(ve[i].begin(), ve[i].end());
            int siz = ve[i].size();
            for (int j = 0; j < siz; ++j)
            {
                int cnt = 1;
                while (j + 1 < siz && ve[i][j] == ve[i][j + 1]) ++j, ++cnt;
                ans += (siz - cnt) * cnt;
            }
        }
        printf("%lld", ans);
        return 0;
    }
    

      

    C

    #include <bits/stdc++.h>
    using namespace std;
    
    const int maxn = 1e5 + 5;
    
    int n, f[maxn], ans, a;
    
    int main()
    {
         scanf("%d", &n);
         for (int i = 1; i <= n; ++i)
         {
             scanf("%d", &a);
             f[a] = f[a - 1] + 1;
             ans = max(ans, f[a]);
         }
         printf("%d", n - ans);
         return 0;
    }
    

      

    D

    #include <bits/stdc++.h>
    #define ll long long
    using namespace std;
    
     ll n;
    vector<ll> ans;
    
    int main()
    {
         scanf("%lld", &n);
         for (ll i = 1; n % i == 0; i *= 5)
             for (ll j = i; n % j == 0; j *= 2)
                 ans.emplace_back(j);
         sort(ans.begin(), ans.end());
         printf("%d
    ", ans.size());
        for (int i = 0; i < ans.size(); ++i) printf("%lld
    ", ans[i]);
        return 0;
    }
    

      

    F

    #include <bits/stdc++.h>
    using namespace std;
     
    int n, len, a[101], k, p[10] = { 1 };
     
    bool dfs(int cnt)
    {
         if (cnt > len) return true;
         for (int i = 1; i <= 99; ++i)
         {
             if (!a[i]) continue;
             int r = cnt - 1 + (i < 10 ? 1 : 2);
             if (r > len) continue;
             int jie = k % p[len + 1 - cnt] / p[len - r];
             if (jie != i) continue;
             --a[i];
             if (dfs(r + 1)) return true;;
             ++a[i];
         }
         return false;
    }
     
    int main()
    {
         for (int i = 1; i <= 9; ++i) p[i] = p[i - 1] * 10;
         scanf("%d%d", &k, &n);
         while (p[++len] < k);
         for (int i = 1; i <= n; ++i) scanf("%d", a), ++a[a[0]];
         for (int i = 1; i <= 99; ++i)
         {
             ++a[i];
             if (dfs(1)) { printf("1"); return 0; }
             --a[i];
         }
         printf("0");
         return 0;
    }
    

      

    G

    #include <bits/stdc++.h>
    using namespace std;
    
    int a[27];
    char s[10000000];
    
    int main()
    {
        scanf("%s", s + 1);
        int flaga = 1, flagb = 1;
        for (int i = 1; s[i]; ++i) ++a[s[i] - 'a'];
        for (int i = 0; i < 26; ++i)
            if (a[i]) 
            {
                if (a[i] & 1) flaga = 0;
                else flagb = 0;
            }
        if (flaga) puts("0");
        else if (flagb)puts("1");
        else puts("2");
        return 0;
    }
    

      

    J

    #include <bits/stdc++.h>
    #define P pair<int, int>
    using namespace std;
     
    int r, d, flag;
    P a, b, c;
     
    int calc(P a, P b)
    {
         return (a.first - b.first) * (a.first - b.first) + 
             (a.second - b.second) * (a.second - b.second);
    }
     
    bool work(P i)
    {
         int dis = calc(i, a);
         if (dis < r * r) {printf("2"); return true;}
         if (dis == r * r) flag = 1;
         return false;
    }
     
    bool work(P a, P b, P c)
    {
         int flag = 0;
         if (a.first >= b.first && a.first <= c.first)
         {
             int dis = min(abs(b.second - a.second), abs(c.second - a.second));
             if (dis == r) flag = 1;
             else if (dis < r) flag = 2;
         }
            if (flag) {printf("%d", flag); return true;}
         return false;
    }
     
    int main()
    {
         scanf("%d%d%d", &a.first, &a.second, &r);
         scanf("%d%d%d", &b.first, &b.second, &d);
         c = {b.first + d, b.second + d};
         if (work(b) || work(c) ||  work({b.first, c.second}) || 
                 work({c.first, b.second}));
         else if (a.first >= b.first && a.first <= c.first && 
                    a.second >= b.second && a.second <= c.second) printf("2");
         else if (work(a, b, c) || work({a.second, a.first}, 
                                        {b.second, b.first}, {c.second, c.first}));
         else if (flag) printf("1");
         else printf("0");
         return 0;
    }
    

      

    K

    #include <bits/stdc++.h>
    #define P pair<int, int>
    using namespace std;
     
    int n, ans, vis[15], flag;
    P a[15], b[15];
     
    bool work(P a, P b, P c)
    {
         if (c.first > a.first && c.first > b.first) return false;
         if (c.first < a.first && c.first < b.first) return false;
         if (c.second > a.second && c.second > b.second) return false;
         if (c.second < a.second && c.second < b.second) return false;
         int b1 = a.second - c.second, b2 = c.second - b.second;
         if (b1 == 0 && b2 == 0) return true;
         if (!b1 || !b2) return false;
         int a1 = a.first - c.first, a2 = c.first - b.first;
         if (a1 * b2 == a2 * b1) return true;
         return false;
    }
     
    void dfs(int k, int cnt)
    {
         if (k == n) { flag = 1; ans = min(ans, cnt); return; }
         if (cnt >= ans) return;
         for (int i = n; i > 1; --i)
         {
             if (vis[i]) continue;
             int flaga = 1;
             for (int j = 1; j <= n && flaga; ++j)
                 if (work(a[i], a[k], b[j])) flaga = 0;
                 else if (j != i && j != k && work(a[i], a[k], a[j])) flaga = 0; 
             if (!flaga) continue;
             vis[i] = 1; dfs(i, cnt + 1); vis[i] = 0;
         }
    }
     
    int main()
    {
         scanf("%d", &n); ans = n - 1;
         for (int i = 1; i <= n; ++i) scanf("%d%d", &a[i].first, &a[i].second);
         for (int i = 1; i <= n; ++i) scanf("%d%d", &b[i].first, &b[i].second);
         dfs(1, 0);
         if (flag) printf("%d", ans);
         else printf("-1");
         return 0;
    }
  • 相关阅读:
    搭建nexus私服(maven)
    maven配置本地仓库(从本地仓库下载jar包到.m2仓库)
    关于引入多个jquery冲突的问题(附一个很好用的validate前端验证框架及使用方法)
    java excel导出
    Eclipse+Maven创建webapp项目 及部署在tomcat上
    solr添加IK分词和自己定义词库
    将Mysq数据导入solr索引库
    solr +zookeeper+Jetty 集群搭建
    solr +zookeeper+tomcat 集群搭建
    如何用Maven创建web项目(具体步骤)转载
  • 原文地址:https://www.cnblogs.com/2aptx4869/p/12575142.html
Copyright © 2020-2023  润新知