您的位置:首页 > 其它

ural 1104 Don’t Ask Woman about Her Age

2014-03-19 19:16 260 查看
http://acm.timus.ru/problem.aspx?space=1&num=1104

#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 2000000
using namespace std;

char s1[maxn];

int main()
{
scanf("%s",s1);
int k=strlen(s1);
char ch='+';
int sum=0;
for(int i=0; i<k; i++)
{
if(s1[i]>ch) ch=s1[i];
if(s1[i]>='0'&&s1[i]<='9') sum+=(s1[i]-'0');
else if(s1[i]>='A'&&s1[i]<'Z') sum+=(s1[i]-'A'+10);
}
int c;
if(ch>='0'&&ch<='9') c=ch-'0';
else c=ch-'A'+10;
if(c+1<2) c=2;
else c++;
for(; c<=36; c++)
{
if(sum%(c-1)==0) break;
}
if(c<=36) printf("%d\n",c);
else if(c>36) printf("No solution.\n");
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: