首页 技术 正文
技术 2022年11月14日
0 收藏 873 点赞 3,939 浏览 790 个字

http://www.bnuoj.com/bnuoj/problem_show.php?pid=20832

【题意】:
 给你一串字符串,求一个ST(0<ST<=10000),对字符串中字符分别加上(ST-‘A’),然后得到的数组分别连起来组成字符串,相邻两个字符相加,取各位数,赋值到下一行,每行讲减少一个字符,直到出现3个字符为100时,输出这时候的ST

【题解】:
 完全暴力模拟
【code】:

 #include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <math.h>
#include <algorithm> using namespace std; int getST(char *names)
{
int a[];
int len = strlen(names);
int i;
int ST;
int b[],cnt=;
for(ST=;ST<=;ST++)
{
for(i=;i<len;i++)
{
a[i]=names[i]-'A'+ST;
}
cnt=;
for(i=len-;i>=;i--)
{
int m = a[i];
while(m)
{
b[cnt]=m%;
m=m/;
cnt++;
}
}
for(i=;i<cnt/;i++)
{
swap(b[i],b[cnt-i-]);
}
int j;
for(i=;i<cnt-;i++)
{
for(j=;j<cnt--i;j++)
{
b[j]=(b[j]+b[j+])%;
}
} if(b[]==&&b[]==&&b[]==) return ST;
}
return -;
} int main()
{
char names[];
while(~scanf("%s",names))
{
int ans = getST(names);
if(ans==-)
{
puts(":(");
}
else
{
printf("%d\n",ans);
}
}
return ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,488
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,903
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,736
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,487
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,127
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,289