//水题,但是考点不水,可能用的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. 把vector中的string对象导入到字符指针数组中

    #include <iostream>#include <string>#include <vector>//#include <cctype>#inc ...

  2. LR11

    HP LoadRunner Readme for the Windows operating system Software version: 11.00 Publication date: Octo ...

  3. studio_ 优化Android Studio 启动、编译和运行速度?

    http://www.admin10000.com/document/6842.html: 作为一名 Android 程序员,选择一个好的 IDE 工具可以使开发变得非常高效,很多程序员喜欢使用 Go ...

  4. Apache2 添加登陆用户名和密码

    1. 修改httpd.conf, 对要做认证的目录进行设置<Directory "/usr/local/var/www">   Options Indexes Foll ...

  5. Java线程专栏文章汇总(转)

    原文:http://blog.csdn.net/ghsau/article/details/17609747 JDK5.0之前传统线程        Java线程(一):线程安全与不安全 Java线程 ...

  6. 播放wav聲音格式

    1. #import <AudioToolbox/AudioToolbox.h> 2.聲明 成員变量 SystemSoundID soundID; 3.播放 - (void)playSou ...

  7. [Swift]枚举

    1. Swift的枚举的基本用法: 1) 和其它语言枚举的意义相同,就是用有限的一组值(不能是无限的)来表示一些特定的含义: 2) Swift使用关键字enum定义枚举类型,定义体中用case定义成员 ...

  8. ThinkPHP CURD返回结果参考

    ThinkPHP CURD返回结果参考: 1)查询$table->find() ##返回一条记录,是一个关联数组,是一维数组.$table->select() ##返回第一维是索引数组,第 ...

  9. 性能测试工具之Gatling

    转载:http://ningandjiao.iteye.com/blog/2004579 Gatling一直是久闻其名但是未得机会运用,正好最近有需求做性能测试,于是趁此机会熟悉了一下,可以说,这是目 ...

  10. [Java] java中的异常处理-续

    异常处理器,它由try, catch, finally以及随后的程序块组成.finally不是必须的. catch的括号有一个参数,代表所要捕捉的异常的类型.catch会捕捉相应的类型及其衍生类.tr ...