字符串基础用法题,包含有大数减法大数除法模板,不难理解,代码如下:

#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<time.h>
#include<iostream>
#include<ctype.h>
#include<map>
#include<set>
#include<algorithm>
#include<stdlib.h>
#include<queue>
#include<stack>
using namespace std;
string a,b,c;
string sub(string a, string b)
{
string c;
bool ok = ;
int len1 = a.length();
int len2 = b.length();
int len = max(len1, len2);
for(int i = len1; i < len; i++)//短的串前边加0方便后边计算
a = "" + a;
for(int i = len2; i < len; i++)
b = "" + b;
if(a < b)//判断正负
{
string temp = a;
a = b;
b = temp;
ok = ;
}
for(int i = len - ; i >= ; i--)
{
if(a[i] < b[i])
{
a[i - ] -= ;
a[i] += ;
}
char temp = a[i] - b[i] + '';
c = temp + c;//此处不能写为c+temp因为是倒着算,需要正着存,顺序写错就不对了,自己可以试几组样例
}
int pos = ;
while(c[pos] == '' && pos < len) pos++;//去除前导0
if(pos == len) return "";
if(ok) return "-" + c.substr(pos);
return c.substr(pos);
} string chufa(string s,int x)
{
int jj=,fla=;
string ans="";
for(int i=; i<s.size(); i++)
{
jj=jj*+s[i]-'';
if(jj>=x)
{
fla=;
ans+=jj/x+'';
jj%=x;
}
else
{
if(fla==)//在运算过程中不够除商0;
ans+='';
}
}
return ans;
}
int main()
{
int n,i,j;
while(cin>>a)
{
set<char>qq;
b=a;
reverse(a.begin(),a.end());
c=sub(b,a);
if(c[]=='-')//题目不要求正负,可以删除再计算
c.erase(,);
if(c.size()==)
{
printf("YES\n");
continue;
}
string ans=chufa(c,); for(int i=; i<ans.size(); i++)
{
qq.insert(ans[i]);
}
if(qq.size()==)
printf("YES\n");
else
printf("NO\n");
}
}

Reversion Count的更多相关文章

  1. 2018宁夏邀请赛网赛 I. Reversion Count(java练习题)

    题目链接 :https://nanti.jisuanke.com/t/26217 Description: There is a positive integer X, X's reversion c ...

  2. 计蒜客——Reversion Count

    Reversion Count 解析:题目数字的长度最大为 99,因此使用字符串处理,那么必然这些数存在某些规律.对于数 a (XYZW) 和数 b (WZYX),原式 = (1000X + 100Y ...

  3. 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 I. Reversion Count (java大数)

    Description: There is a positive integer X, X's reversion count is Y. For example, X=123, Y=321; X=1 ...

  4. 2018 ACM-ICPC 中国大学生程序设计竞赛暨丝绸之路程序设计竞赛

    三道大水题,其它题都不会做,真是尴尬和无奈啊…… 有想法,但是解决不了,感觉个人不会一些基本解法,终究还是个人学习的内容太少了 B. Goldbach /* 数值较小,<2^63,分解的两个素数 ...

  5. nodejs api 中文文档

    文档首页 英文版文档 本作品采用知识共享署名-非商业性使用 3.0 未本地化版本许可协议进行许可. Node.js v0.10.18 手册 & 文档 索引 | 在单一页面中浏览 | JSON格 ...

  6. C#中Length和Count的区别(个人观点)

    这篇文章将会很短...短到比你的JJ还短,当然开玩笑了.网上有说过Length和count的区别,都是很含糊的,我没有发现有 文章说得比较透彻的,所以,虽然这篇文章很短,我还是希望能留在首页,听听大家 ...

  7. [PHP源码阅读]count函数

    在PHP编程中,在遍历数组的时候经常需要先计算数组的长度作为循环结束的判断条件,而在PHP里面对数组的操作是很频繁的,因此count也算是一个常用函数,下面研究一下count函数的具体实现. 我在gi ...

  8. EntityFramework.Extended 实现 update count+=1

    在使用 EF 的时候,EntityFramework.Extended 的作用:使IQueryable<T>转换为update table set ...,这样使我们在修改实体对象的时候, ...

  9. 学习笔记 MYSQL报错注入(count()、rand()、group by)

    首先看下常见的攻击载荷,如下: select count(*),(floor(rand(0)*2))x from table group by x; 然后对于攻击载荷进行解释, floor(rand( ...

随机推荐

  1. 每日linux命令学习-历史指令查询(history、fc、alias)

    linux历史机制对命令行中输入的命令进行编号并依此保存,以维护命令历史.登录会话期间输入的命令保存在shell内存中,若终止命令则添加至历史文件. 1. 箭头符号方向键 使用键盘上的箭头方向键可以从 ...

  2. 求N!的二进制表示中最低位1的位置。(编程之美)

    要求的是N!的二进制表示中最低位1的位置.给定一个整数N,求N!二进制表示的最低位1在第几位?例如:给定N = 3,N!= 6,那么N!的二进制表示(1 010)的最低位1在第二位. 为了得到更好的解 ...

  3. EditPlus配置GTK

    --GCC GTK Compile-- 命令:D:\GCC\MinGW_RP_Green\bin\gcc.exe 参数:$(FileName) -w -o $(FileNameNoExt).exe - ...

  4. mybatis总结之一

    今日内容:mybatis数据持久层的一种表现,在一定程度上,取代了jdbc. 1.建maven...... 在pom.xml中进行配置,添加mabatis包,junit测试jar包,添加连接mysql ...

  5. 看起来像是break的考量

    代码运用了if+break: package day20181008; import java.util.Scanner; public class ZuoYe01 { public static v ...

  6. 20145315何佳蕾《网络对抗》web基础

    实验步骤 (1).Web前端HTML(1分) 能正常安装.启停Apache.理解HTML,理解表单,理解GET与POST方法,编写一个含有表单的HTML. (2).Web前端javascipt(1分) ...

  7. vue.js not detected 解决办法-vue.js devtools 安装

    国外网站:https://www.crx4chrome.com/ 国内网站:http://www.cnplugins.com/ http://chromecj.com/web-development/ ...

  8. hdu 1394 Minimum Inversion Number - 树状数组

    The inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that ...

  9. JavaScript中字符串的方法:charAt()、charCodeAt()、indexOf()、lastIndexOf()、substr()、slice()、substring()、search()、replace()、split()、concat()、toLowerCase()、toUpperCase()

    1.字符创的创建: //1.通过new 来创建 var str = String("javascript"); //2.3.直接使用字面量进行创建 var str='html5'; ...

  10. Python3 tkinter基础 grid(row,column) 窗体的布局

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...