//水题,但是考点不水,可能用的strlen属于string库,但是只能用于字符,不能用数字,因为\0就是0.出现0无法判断,其次二倍时有可能有进位

//第一次在二倍进位上出了问题

 #include<stdio.h>
#include<string.h>
int main()
{
//freopen("input.txt","r",stdin);
char s[];
int s1[];
int has[];
memset(has,,sizeof(has));
scanf("%s",s);
int i,len=strlen(s);
for(i=;i<len;i++) //hash
{
has[s[i]-'']++;
}
int c=,len1=;
for(i=len-;i>=;i--) //计算2倍
{
int m=c+(s[i]-'')*;
has[m%]--; //hash 比较
s1[len1++]=m%;
c=m/;
}
if(c!=)s1[len1++]=c;
if(len1!=len)printf("No\n"); //进位
else{
for(i=;i<;i++)
if(has[i]!=)break; //出现次数不一样
if(i<)printf("No\n");
else printf("Yes\n");
}
for(i=len1-;i>=;i--) //不论yes or no 输出
printf("%d",s1[i]);
printf("\n");
}

PAT1023. Have Fun with Numbers的更多相关文章

  1. PAT1023. Have Fun with Numbers (20)

    #include <iostream> #include <map> #include <algorithm> using namespace std; strin ...

  2. Java 位运算2-LeetCode 201 Bitwise AND of Numbers Range

    在Java位运算总结-leetcode题目博文中总结了Java提供的按位运算操作符,今天又碰到LeetCode中一道按位操作的题目 Given a range [m, n] where 0 <= ...

  3. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  4. [LeetCode] Add Two Numbers II 两个数字相加之二

    You are given two linked lists representing two non-negative numbers. The most significant digit com ...

  5. [LeetCode] Maximum XOR of Two Numbers in an Array 数组中异或值最大的两个数字

    Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. Find the maximum re ...

  6. [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  7. [LeetCode] Bitwise AND of Numbers Range 数字范围位相与

    Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers ...

  8. [LeetCode] Valid Phone Numbers 验证电话号码

    Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bas ...

  9. [LeetCode] Consecutive Numbers 连续的数字

    Write a SQL query to find all numbers that appear at least three times consecutively. +----+-----+ | ...

随机推荐

  1. hibernate级联与反向

    cascade:设置本表与关联表之间的级联操作,如:设置为save-update,则插入或更新对象时同时保存或更新另一端的表,但不会产生关联关系数据,除非inverse为false. inverse: ...

  2. ADO.NET基础(增删改查)

    ADO.NET是一种数据访问技术,就是将C#和MSSQL连接起来的一个纽带.可以通过ADO.NET将内存中的临时数据写入到数据库中,也可以将数据库中的数据提取到内存中供程序调用. ADO.NET是所有 ...

  3. git(5) windows下 pycharm + git(github) ,在本地方便管理

    本篇博客讲解一下,windows下如何在pycharm下使用git(使用github设置和git一样),在本地进行commit,push,pull等操作 优点:简单,方便 pycharm版本:5.0. ...

  4. maven打成war包之后没有class文件

    用maven打了war包之后部署到tomcat下居然无法执行,看了一下原来没有任何编译的.class文件. 查了一下,是自己手欠把source的src改成src.main.java之类的目录了,但是没 ...

  5. 内网Linux对公网开启SSH

    1.首先你得装个Linux,过程就不说了.Linux可以装在Vmware上,但是网络适配器选项选的是桥接模式 2.在linux上安装SSH服务,如果有就自动忽略 3.在路由器上开启端口映射. 这里我用 ...

  6. Ubuntu打开终端和设置root密码(转载)

    From:http://blog.csdn.net/xhhjin/article/details/6328752 http://www.linuxsir.org/bbs/thread318516.ht ...

  7. ConcurrentHashMap使用要点

    ConcurrentHashMap的简要总结: 1.public V get(Object key)不涉及到锁,也就是说获得对象时没有使用锁: 2.put.remove方法要使用锁,但并不一定有锁争用 ...

  8. 异步task处理

    public async Task<Customers> GetCustomers() { return await Service.GetCustomersAsync(); } publ ...

  9. 名词解释:DRAM, SRAM, SDRAM等

    SRAM:静态RAM,不用刷新,速度可以非常快,像CPU内部的cache,都是静态RAM,缺点是一个内存单元需要的晶体管数量多,因而价格昂贵,容量不大. DRAM:动态RAM,需要刷新,容量大. SD ...

  10. [Java] 读写字符串数据

    package test.stream; import java.io.FileInputStream; import java.io.FileNotFoundException; import ja ...