Skip to content

Instantly share code, notes, and snippets.

@sakapon
Created May 31, 2021 09:22
Show Gist options
  • Save sakapon/0a32004394bc6ef63f1f0f473b4ab9cd to your computer and use it in GitHub Desktop.
Save sakapon/0a32004394bc6ef63f1f0f473b4ab9cd to your computer and use it in GitHub Desktop.
競プロ典型 90 問 / Q008
using System;
class Q008
{
const string AtCoder = "atcoder";
const long M = 1000000007;
static void Main()
{
var n = int.Parse(Console.ReadLine());
var s = Console.ReadLine();
var dp = new long[AtCoder.Length + 1];
dp[0] = 1;
foreach (var c in s)
{
var i = AtCoder.IndexOf(c);
if (i == -1) continue;
dp[i + 1] += dp[i];
dp[i + 1] %= M;
}
Console.WriteLine(dp[^1]);
}
}
@sakapon
Copy link
Author

sakapon commented Jun 1, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment