• UCF Local Programming Contest 2015


    UCF Local Programming Contest 2015

    A. Find the Twins

    • 思路:水题

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    int n;
    int a[11];
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> n;
        while (n -- ){
            bool flag1 = false, flag2 = false;
            for (int i = 1; i <= 10; i ++ ){
                cin >> a[i];
                if (a[i] == 17)
                    flag1 = true;
                if (a[i] == 18)
                    flag2 = true;
            }
            for (int i = 1; i < 10; i ++ )
                cout << a[i] << " ";
            cout << a[10] << "
    ";
            if (flag1 && flag2)
                cout << "both
    
    ";
            else if (flag1 && !flag2)
                cout << "zack
    
    ";
            else if (!flag1 && flag2)
                cout << "mack
    
    ";
            else
                cout << "none
    
    ";
        }
        return 0;
    }
    

    B. Medal Ranking

    • 思路:水题

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    int n;
    int a[7];
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> n;
        while (n -- ){
            for (int i = 1; i <= 6; i ++ )
                cin >> a[i];
            for (int i = 1; i < 6; i ++ )
                cout << a[i] << " ";
            cout << a[6] << "
    ";
            bool flag1 = false, flag2 = false;
            if (a[1] + a[2] + a[3] > a[4] + a[5] + a[6])
                flag1 = true;
            if (a[1] > a[4])
                flag2 = true;
            else if (a[1] == a[4] && a[2] > a[5])
                flag2 = true;
            else if (a[1] == a[4] && a[2] == a[5] && a[3] > a[6])
                flag2 = true;
            else
                flag2 = false;
            if (flag1 && flag2)
                cout << "both
    
    ";
            else if (flag1 && !flag2)
                cout << "count
    
    ";
            else if (!flag1 && flag2)
                cout << "color
    
    ";
            else
                cout << "none
    
    ";
        }
        return 0;
    }
    

    C. Brownies vs. Candies vs. Cookies

    • 思路:水题

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    int t, n, num, cnt, x;
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> t;
        for (int k = 1; k <= t; k ++ ){
            cin >> n >> num >> cnt;
            cout << "Practice #" << k << ": " << n << " " << num << "
    ";
            for (int i = 1; i <= cnt; i ++ ){
                cin >> x;
                if (num > x)
                    num -= x;
                else{
                    while (num <= x)
                        num *= 2;
                    num -= x;
                }
                cout << x << " " << num << "
    ";
            }
            cout << "
    ";
        }
        return 0;
    }
    

    D. Lemonade Stand

    • 思路:阅读题 读完照着模拟

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    int n, d, x, s, c, pl, ps, min_pl, min_ps, cnt, num, ans;
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> n;
        while (n -- ){
            min_pl = 55, min_ps = 505, num = 0, ans = 0;
            cin >> d >> x >> s;
            while (d -- ){
                cnt = 0;
                cin >> c >> pl >> ps;
                if (pl < min_pl)
                    min_pl = pl;
                if (ps < min_ps)
                    min_ps = ps;
                while (num < c * s){
                    cnt ++ ;
                    num += 80;
                }
                num -= c * s;
                ans += c * x * min_pl + cnt * min_ps;
            }
            cout << ans << "
    ";
        }
        return 0;
    }
    

    E. Rain Gauge

    • 思路:我是智障 wa9 很简单的二维几何题 第二个判断条件一直写错了一直没发现

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    const double pi = 3.14159265358979;
    const double eps = 1e-5;
    
    int t;
    double s, r, len, x, ans;
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> t;
        while (t -- ){
            cin >> s >> r;
            len = sqrt(2.0) * s / 2.0;
            if (len < r)
                ans = s * s;
            else if (r < s / 2.0)
                ans = pi * r * r;
            else{
                double delta = 4.0 * s * s - 2.0 * 4.0 * (s * s - 2.0 * r * r);
                x = (2.0 * s - sqrt(delta)) / 4.0;
                double alpha = acos((r * r + r * r - 2.0 * x * x) / (2.0 * r * r));
                double beta = pi / 2.0 - alpha;
                double a = s - 2.0 * x;
                double h = sqrt(r * r - (a / 2.0) * (a / 2.0));
                ans = 4.0 * alpha * r * r / 2.0 + 4.0 * a * h / 2.0;
            }
            cout << fixed << setprecision(2) << ans << "
    ";
        }
        return 0;
    }
    

    G. Towers of Hanoi Grid

    • 思路:仔细想一下不难得出 (d leq n * (n - 2) + 2)时才满足 (ans = d * (2 * n - 2))

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    int t, d, n;
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> t;
        for (int i = 1; i <= t; i ++ ){
            cin >> d >> n;
            cout << "Grid #" << i << ": ";
            if (d > n * (n - 2) + 2)
                cout << "impossible
    
    ";
            else
                cout << d * (2 * n - 2) << "
    
    ";
        }
        return 0;
    }
    
  • 相关阅读:
    英语中容易混淆单词
    Centos7 中安装 Redis 6.0.6
    JAVA基础- 为啥 Integer 中100=100 为true 而200=200则为false
    Java面试BIO,NIO,AIO 的区别
    Maven 中 dependencyManagement 干嘛用的
    代理实现流程
    使用do...while的方法输入一个月中所有的周日
    JavaScript---while和do while的区别
    微信小程序和H5之间相互跳转
    微信小程序进入广告实现
  • 原文地址:https://www.cnblogs.com/Misuchii/p/12485519.html
Copyright © 2020-2023  润新知