51nod 1116 K进制下的大数
你万万想不到,Long Long 就能存下的数据
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <map>
using namespace std;
typedef long long ll;
map<char,int>mp;
int main()
{ string s;
while(cin>>s){
int max1=-1;
int max2=-1;
bool flag=false;
bool kk=false;
for(int i=0;i<s.length();i++){
if(s[i]>='A'&&s[i]<='Z')
{flag=true;
max2=max(max2,s[i]-'A');
}
else if(s[i]>='0'&&s[i]<='9')
max1=max(max1,s[i]-'0');
}
if(!flag){
for(int i=max1+1;i<=36;i++){
ll k=1;
ll sum=0;
for(int j=0;j<s.length();j++){
sum=sum*i+1ll*(s[j]-'0');
sum%=(i-1);
}
if(!sum)
{printf("%d\n",i);kk=true;break;}
}
}
else{
for(int i=max2+11;i<=36;i++){
ll k=1;
ll sum=0;
for(int j=0;j<s.length();j++){
if(s[j]>='0'&&s[j]<='9')
sum =1ll*(s[j]-'0')+sum*i;
else
sum=1ll*(s[j]-'A'+10)+sum*i;
sum%=(i-1);
}
//if(i==22)
//cout<<sum<<"@@@@"<<endl;
if(!sum)
{printf("%d\n",i);
//cout<<"!!"<<max2+11<<endl;
//cout<<sum<<endl;
//cout<<(i-1)<<endl;
kk=true;
break;}
}
}
if(!kk)
puts("No solution");
}
return 0;
}
51nod 1116 K进制下的大数的更多相关文章
- 51nod 1116 K进制下的大数 (暴力枚举)
题目链接 题意:中文题. 题解:暴力枚举. #include <iostream> #include <cstring> using namespace std; ; ; ch ...
- 51Nod 1116 K进制下的大数(暴力枚举)
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> us ...
- 51 Nod 1116 K进制下的大数
1116 K进制下的大数 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 收藏 关注 有一个字符串S,记录了一个大数,但不知这个大数是多少进制的,只知道这个数 ...
- [51nod1116]K进制下的大数
解题关键:$A\% (k - 1) = (A[0] + A[1]*k + A[2]*{k^2} + ...A[n]*{k^n})\% (k - 1) = (A[0] + A[1] + ...A[n]) ...
- A - K进制下的大数
https://vjudge.net/contest/218366#problem/A 中间溢出,注意求模. #include<iostream> #include<cstdio&g ...
- n!在k进制下的后缀0
问n! 转化成k进制后的位数和尾数的0的个数.[UVA 10061 How many zeros and how many digits?] Given a decimal integer numbe ...
- bzoj 3000 Big Number 估算n!在k进制下的位数 斯特林公式
题目大意 求n!在k进制下的位数 2≤N≤2^31, 2≤K≤200 分析 作为数学没学好的傻嗨,我们先回顾一下log函数 \(\log_a(b)=\frac 1 {log_b(a)}\) \(\lo ...
- 求x!在k进制下后缀零的个数(洛谷月赛T1)
求x!在k进制下后缀和的个数 20分: 求十进制下的x!后缀和的个数 40分: 高精求阶乘,直接模拟过程 (我不管反正我不打,本蒟蒻最讨厌高精了) 60分 利用一个定理(网上有求x!在 ...
- 陕西师范大学第七届程序设计竞赛网络同步赛 F WWX的礼物【数学/k进制下x^n的位数/log】
链接:https://www.nowcoder.com/acm/contest/121/F来源:牛客网 题目描述 WWX的女朋友送给了他一个礼物,可是礼物却被一把K进制密码锁锁住了.在礼物盒上还有一张 ...
随机推荐
- Eclipse的Servers视图中无法添加Tomcat6/Tomcat7
原文:http://blog.csdn.net/blueheart20/article/details/40043749 问题的提出: 无法从以下方式,添加Tomcat服务器. 其中ServerNa ...
- weblogic负载分发
博客分类: weblogic 负载均衡的实现方式有很多种,这里只介绍三种相对来说成本较低的方案(维护成本以及费用成本)weblogic自带的proxy.apache.nginx 1.weblogic自 ...
- [Node.js] Write or Append to a File in Node.js with fs.writeFile and fs.writeFileSync
In node.js, you can require fs, and then call fs.writeFile with the filename, and data to write to t ...
- [Javascript] Link to Other Objects through the JavaScript Prototype Chain
Objects have the ability to use data and methods that other objects contain, as long as it lives on ...
- oracle随机数
1.从表中随机取记录 select * from (select * from staff order by dbms_random.random) where rownum < 4 表示从ST ...
- C# LINQ Unity 单例
C# LINQ 1. 自定义 Master,Kongfu 类 1 class Master 2 { 3 4 public int Id { get; set; } 5 public string ...
- CodeForces 567C. Geometric Progression(map 数学啊)
题目链接:http://codeforces.com/problemset/problem/567/C C. Geometric Progression time limit per test 1 s ...
- HBuilder开发App教程05-滴石和websql
滴石 介绍 滴石是用HBuilder开发的一款计划类app. 用到HBuilder,mui.nativejs以及h5一些特性. 预期 眼下仅仅开发到todolist级别, 以后计划做成日计划,月计划, ...
- 实现@using{}代码块
前几天,我要写个插件,放在asp.net mvc的view上.这需要写一些扩展HtmlHelper功能的方法.这些方法的一个参数是一段javascript代码. 假如这个参数类型是字符型,当然很简单了 ...
- CRM2011部署问题小结
1 CRM2011部署当插件太多,并且文件太多的时候选择硬盘部署 2 在生产环境这样复杂的CRM2011部署环境的时候弄清楚每台CRM服务器的结构是很重要的弟一步 3 一定要注意DMZ区和内网隔离的, ...