#309 (div.2) A. Kyoya and Photobooks

1.题目描述:点击打开链接

2.解题思路:本题实质上在问:给定一个长为L的字符串,在26个字符中选一个字符插入该串,可以形成多少个新的字符串。这就是一个简单的计数问题,长度为L的字符串有L+1个空位可以插入,一共有26*(L+1)个方法,考虑到相同字符的情况,要减去一个,一共有L种重复的情况,因此最终有26*(L+1)-L=25*(L+1)+1种情况。

3.代码:

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<queue>
#include<deque>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime>
#include<functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define me(s) memset(s,0,sizeof(s))
#define For(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz size
#define clr clear
#define F(a,b) for(int i=a;b;i++)

int main()
{
    string s;
    while(cin>>s)
    {
        int len=s.length();
        int ans=(len+1)*25+1;
        printf("%d\n",ans);
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-12-04 11:39:03

#309 (div.2) A. Kyoya and Photobooks的相关文章

找规律 Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks

题目传送门 1 /* 2 找规律,水 3 */ 4 #include <cstdio> 5 #include <iostream> 6 #include <algorithm> 7 #include <cstring> 8 #include <cmath> 9 using namespace std; 10 11 const int MAXN = 1e4 + 10; 12 const int INF = 0x3f3f3f3f; 13 char s

Codeforces Round #309 (Div. 2) C. Kyoya and Colored Balls

Kyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are labeled from 1 to k. Balls of the same color are indistinguishable. He draws balls from the bag one by one until the bag is empty. He noticed that he

A. Kyoya and Photobooks(Codeforces Round #309 (Div. 2))

A. Kyoya and Photobooks Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photo

cf #309a A - Kyoya and Photobooks

A - Kyoya and Photobooks Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Description Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z&

贪心 Codeforces Round #309 (Div. 2) B. Ohana Cleans Up

题目传送门 1 /* 2 题意:某几列的数字翻转,使得某些行全为1,求出最多能有几行 3 想了好久都没有思路,看了代码才知道不用蠢办法,匹配初始相同的行最多能有几对就好了,不必翻转 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 #include <string> 8 #include <cmath> 9 #include <iostream> 10 using namespace std; 1

C. Kyoya and Colored Balls(Codeforces Round #309 (Div. 2))

C. Kyoya and Colored Balls Kyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are labeled from 1 to k. Balls of the same color are indistinguishable. He draws balls from the bag one by one until the bag i

Codeforces554A:Kyoya and Photobooks

Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A p

Codeforces Round #309 (Div. 2)

A. Kyoya and Colored Balls 一个背包有K种颜色一共N个球,颜色分别为1,2,3...K,颜色相同的球是不区别的.现在从背包里一个一个拿球直到所有球拿光,在拿光第I+1种颜色球之前一定要拿光第I种颜色的球,求有多少种拿法 如 果只有一种颜色的球,拿的方法只有一种.如果有两种,留下一个颜色为2的放在最后一个,剩下的N1个颜色1和N2-1个颜色2的可以随意摆,方法数为 1*\(N1+N2-1 \choose N2-1\):如果有三种相当于先排好颜色为1,2的,然后剩下N3-1

B. Ohana Cleans Up(Codeforces Round #309 (Div. 2))

B. Ohana Cleans Up Ohana Matsumae is trying to clean a room, which is divided up into an n by n grid of squares. Each square is initially either clean or dirty. Ohana can sweep her broom over columns of the grid. Her broom is very strange: if she swe