7.13补题

 chokudai

题意 在字符串中计算组成chokudai的数量并mod 1e9+7。

思路

数量的计算不是乘而是相加,取决于某个字符前面的字符的个数。所以遍历一遍字符串,将每个字符对应的字符数记录下来,最后i前面的数就是答案。因为顺序遍历所以后面出现的字符不会对前面有影响。

#define _CRT_SECURE_NO_WARNINGS 1;
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <unordered_map>
using namespace std;
#define off ios::sync_with_stdio(false);
#define INF 0x3f3f3f3f
#define forn(i,n) for(int i = 0; i < int(n); i++)

const int N = 1e5 + 10;
const int M = 2e7 + 10;
const int mod = 1e9 + 7;
typedef pair<int, int> PII;
typedef long long ll;

int c, h, o, k, u, d, a, I;

int main()
{
    string s;
    cin >> s;
    forn(i, s.size()) {
        if (s[i] == 'c') c++;
        else if (s[i] == 'h') h = (h + c) % mod;
        else if (s[i] == 'o') o = (o + h) % mod;
        else if (s[i] == 'k') k = (k + o) % mod;
        else if (s[i] == 'u') u = (u + k) % mod;
        else if (s[i] == 'd') d = (u + d) % mod;
        else if (s[i] == 'a') a = (a + d) % mod;
        else if (s[i] == 'i') I= (a + I) % mod;
    }
    cout << I << endl;
    return 0;
}

Five Transportations

题意

N个人从1去6号城市,每个城市之间的运输工具最多运A,B,C,D,E个人,每次一分钟,问所有人到6号所需的最短时间。

思路

可以想到如果ABCDE均大于N那么时间就是5,所以只需要找哪个数最小,最小的对于整个时间影响最大。

#define _CRT_SECURE_NO_WARNINGS 1;
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <unordered_map>
using namespace std;
#define off ios::sync_with_stdio(false);
#define INF 0x3f3f3f3f
#define forn(i,n) for(int i = 0; i < int(n); i++)

const int N = 1e5 + 10;
const int M = 2e7 + 10;
const int mod = 1e9 + 7;
typedef pair<int, int> PII;
typedef long long ll;

int main()
{
    off;

    ll n;
    ll a[6];
    ll ans = 0;
    cin >> n;
    ll m = INF;
    forn(i, 5) {
        cin >> a[i];
        m = min(m, a[i]);
    }
    if (n % m) {
        ans += n / m + 5;
    }
    else ans += n / m + 4;
    cout << ans << endl;
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值