求助 Wa 50
查看原帖
求助 Wa 50
938449
xiaoming007楼主2023/11/9 06:22
#include <ctime>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
#define int long long
#define debug puts("qwq")
#define open(x) freopen(#x".in", "r", stdin);freopen(#x".out", "w", stdout);
#define close fclose(stdin);fclose(stdout);
#define aint(x) x.begin(), x.end()
namespace FastIO {
	template <typename T = int>
	inline T read() {
		T s = 0, w = 1;
		char c = getchar();
		while (!isdigit(c)) {
			if (c == '-') w = -1;
			c = getchar();
		}
		while (isdigit(c)) s = (s << 1) + (s << 3) + (c ^ 48), c = getchar();
		return s * w;
	}
	template <typename T>
	inline void read(T &s) {
		s = 0;
		int w = 1;
		char c = getchar();
		while (!isdigit(c)) {
			if (c == '-') w = -1;
			c = getchar();
		}
		while (isdigit(c)) s = (s << 1) + (s << 3) + (c ^ 48), c = getchar();
		s = s * w;
	}
	template <typename T, typename... Args> inline void read(T &x, Args &...args) {
		read(x), read(args...);
	}
	template <typename T>
	inline void write(T x, char ch) {
		if (x < 0) x = -x, putchar('-');
		static char stk[25];
		int top = 0;
		do {
			stk[top++] = x % 10 + '0', x /= 10;
		} while (x);
		while (top) putchar(stk[--top]);
		putchar(ch);
		return;
	}
} using namespace FastIO;
int dp[101];
const int mod = 1e9+7;
signed main() {
	dp[0] = 1;
	string s;
	while (cin >> s) {
		for (auto&i : s) {
			if (i <= 'Z') i += 32;
			if (i == 'h') dp[1] ++;
			else if (i == 'e') (dp[2] += dp[1]) %= mod;
			else if (i == 'l') {
				(dp[9] += dp[8]) %= mod;
				(dp[4] += dp[3]) %= mod;
				(dp[3] += dp[2]) %= mod;
			} else if (i == 'o') {
				(dp[5] += dp[4]) %= mod;
				(dp[7] += dp[6]) %= mod;
			} else if (i == 'w') (dp[6] += dp[5]) %= mod;
			else if (i == 'r') (dp[8] += dp[7]) %= mod;
			else if (i == 'd') (dp[10] += dp[9]) % mod;
		}
	}
	cout << dp[10] << '\n';
	return 0;
}

看上去和题解没什么两样。

2023/11/9 06:22
加载中...