长安大学第三届ACM-ICPC程序设计竞赛【A E L】

A Unpredictable Accidents

链接:https://www.nowcoder.com/acm/contest/102/A
来源:牛客网
题目描述
Due to unpredictable accidents, The Third Chang′an University ACM−ICPC Programming Competition will be postponed for x minutes. We have known that the competition should have started at 12:00, and the duration of it is 5 hours. As a participant, you want to know when is the ending time.
Please print the ending time in the form of hh:mm, hh is the hours with range of 00 to 24 and the mm is the minutes with range of 00 to 59.
输入描述:
The first line contains an integer number T,the number of test cases.
ith of each next T lines contains an integer x(1≤x≤300), the number of minutes competition will postpone.
输出描述:
For each test case print the the ending time in the form of hh:mm.
示例1
输入
3
5
70
120
输出
12:05
13:10
14:00

题意:12点开始比赛,过了x分钟后几点几分了;

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main() {
    int T, n;
    scanf("%d", &T);
    while(T--) {
        scanf("%d", &n);
        int m = n % 60;
        n /= 60;
        printf("%d:%02d\n", 12 + n, m);
    }
    return 0;
}

E Cellular Mobile Communication
题意:n个正六边形,二维平面拼接,求露在外侧的最少边;
分析:找规律。。。

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

int main() {
    int T;
    scanf("%d", &T);
    while(T--) {
        double n;
        scanf("%lf", &n);
        printf("%.0lf\n", 2 * ceil(sqrt(12 * n - 3)));
    }
    return 0;
}

L Big Boss

链接:https://www.nowcoder.com/acm/contest/102/L
来源:牛客网
题目描述
Many years later, Rainbow Island is in the mercy of big boss qiami. Big boss qiami is fond of number 9 because each side of the magic cube is made up of 9 small pieces and he changes the face value of circulating currency to 90,91,92,93,94 Yuan.
One day programmer Uucloud went to a shop to buy Cat food worth n Yuan. The shopkeeper NoMoreWords and Uucloud are good friends so he will give Uucloud his change. Uucloud wants to know how many bills do they need in their trade at least.
For example, if Uucloud wants to buy cat food of 8 Yuan, he will pay a 9 Yuan bill and NoMoreWords will give Uucloud 1 Yuan bill as change. Two paper money are used in this trade.
输入描述:
The first line contains an integer number T, the number of test cases.
Next T lines contains a number n(1 ≤ n ≤ 109)。
输出描述:
For each test case print the number of bills they need at least.
示例1
输入
2
14
18
输出
6
2

题意:不翻译了,题读不了,补个屁的题呀;
分析:这道题写着有意思啦(一丢丢bug坑坏了。。。)
比如:8你可以9 - 1,4就只能4+0了;10可以选择9+1,17可以选择9 * 2 - 1 …
其实就是两个选择,反着和正着。总共就5种纸币直接dfs就行,但是注意一个贪心小技巧:5 = 5 + 0用5张,6 = 9 - 3用4张,所以注意反着dfs的时候,注意贪心选择:ans - num <= num。

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

LL arr[15];
LL tot = 1e9;

inline void dfs(LL num, LL ans, int id) {
    if(num <= 5 && num >= 0) {
//      printf("#: %d\n", num);
        tot = min(tot, ans + num);
        return ;
    }
    if(num < 0) return ;
    for(int i = id; i >= 0; --i) {
        if(num >= arr[i]) {
            if(arr[i + 1] - num <= num) dfs(arr[i + 1] - num, ans + 1, i);
            dfs(num % arr[i], ans + num / arr[i], i - 1);
            break;
        }
    }
}

inline void init() {
    LL ans = 1;
    arr[0] = 1;
    for(int i = 1; i <= 4; ++i) {
        ans *= 9;
        arr[i] = ans;
    }
}

int main() {   
//  freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    LL T, n; init();
    int p = 1;
    scanf("%lld", &T);
    while(T--) {
        tot = 1e9;
        scanf("%lld", &n);
        LL sum = 0;
        sum = sum + n / arr[4];
        n %= arr[4];
        dfs(n, 0, 3);
        printf("%lld\n", tot + sum);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_36368339/article/details/79944465