链接:http://pat.zju.edu.cn/contests/pat-a-practise/1019
题意:给定一个十进制数和一个进制,判断该数字在该进制下是否为回文。
分析:简单的数字进制处理。
#include<stdio.h> int numStr[100]; int idx; int palindrome(int num,int radix){ if(num==0) return 1; int rem; while(num){ rem=num%radix; num/=radix; numStr[idx++]=rem; } int i; for(i=0;i<=idx/2;i++){ if(numStr[i]!=numStr[idx-1-i]) return 0; } return 1; } int main(){ int n,b; scanf("%d%d",&n,&b); if(n==0){ printf("Yes\n"); printf("0\n"); return 0; } if(palindrome(n,b)) printf("Yes\n"); else printf("No\n"); int i; for(i=idx-1;i>=0;i--){ printf("%d",numStr[i]); if(i) printf(" "); } printf("\n"); return 0; }
相关推荐
原创:PAT 1019 General Palindromic Number (20 分)A number that will be the same when
PAT甲级 1024 Palindromic Number A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit...
在计算机科学和信息学中,回文数(Palindromic Number)是一种数字,它从左向右念和从右向左念都一样。例如,12321是一个典型的回文数。给定一个进制B(2<=B<=20,十进制表示),输出所有的大于等于1小于等于300(十...
Palindromic Substring 20.Valid Parentheses 26.Remove Duplicates from Sorted Array 53.Maximum Subarray 70.Climbing Stairs 121.Best Time to Buy and Sell Stock 122.Best Time to Buy and Sell Stock II 123....
Palindromic Substring 7. Reverse Integer 9. Palindrome Number 11. Container With Most Water 12. Integer to Roman 13. Roman to Integer 14. Longest Common Prefix 15. 3Sum 20. Valid Parentheses 21. Merge...
zoj 3661 Palindromic Substring.md
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Java AC 版本
Palindromic Substring (Manacher算法待完成) 6.ZigZag Conversion 7.Reverse Integer 8.String to Integer (atoi) 9.Palindrome Number 10.Regular Expression Matching 11.Container With Most Water 12.Integer ...
Palindromic Substring 006. ZigZag Conversion 007. Reverse Integer 008. String to Integer 009. Palindrome Number 010. Regular Expression Matching 011. Container With Most Water 012. Integer to Roman ...
Palindromic Substring 6.ZigZag Conversion 7.Reverse Integer 8.String To Integer 9.Palindrome Number 10.String To Integer 11.Container With Most Water 12.Integer To Roman 13.Roman To Integer 289 347 ...
Palindromic Substring 最长回文子串 6. ZigZag Conversion Z字型变换 7. Reverse Integer 整数反转 8. String to Integer (atoi) 字符串转换整数 (atoi) 9. Palindrome Number 回文数 10. Regular Expression ...
leetcode 516 8/13 - 8/18 周:leetcode#: 409. longestPalindrome 125. Valid Palindrome ...Palindromic Substring option: 516. Longest Palindromic Subsequence string replacement strStr II 链接:
回文数要确定是否需要取消费用,必须先确定是否需要取消费用。 Elnúmerodebe ser市长de 2dígitos。 Desarrollar unaaplicaciónque ingrese dosnúmerosy se cambien las posiciones pares del底漆númerocon el ...
leetcode信封 ...Palindromic Substring │ RansomNote.java //383. Ransom Note │ RussianDollEnvelope.java //354. Russian Doll Envelopes │ SlidingWindowMaximum.java //239. Sliding Window Maximum
c c语言_leetcode 0005_longest_palindromic_substring.zip
题目名称:**Palindromic Substrings** 题目描述: 给定一个字符串 `s`,你需要找到并输出该字符串中所有长度为偶数的回文子串的数量。 输入: 输入包含一行,为一个字符串 `s`(只包含小写字母,长度不超过 `10^5...
c语言入门 c语言_leetcode题解05-longest-palindromic-substring.c
js js_leetcode题解之5-longest-palindromic-substring.js
眼镜创建一个名为palindromeNumberGenerator的函数,该函数采用一个Number值。 检查数字是否为回文数,如果不是,则将值和取反的值相加,并检查总和是否为回文数,重复直到达到回文数值。 每次对这些值求和以获取新...
Palindromic Substring 最长回文子串,补符号,记忆 6. ZigZag Conversion 观察规律 7. Reverse Integer 翻转整数 8. String to Integer 解析字符串 9. Palindrome Number 回文数字 10. Regular Expression Matching...