当前位置:网站首页>1019 general palindromic number (20 points)
1019 general palindromic number (20 points)
2022-06-30 14:55:00 【Xue Dongjing】
1019 General Palindromic Number (20 branch )
The question
Give me two numbers N and b, seek N stay b Base represents the result and determines whether the result is a palindrome digit .( The first and last numbers are the same , The second and penultimate numbers are the same …)
Ideas
Hexadecimal conversion , use N Yes b Quotient and remainder N stay b The result in base , Then judge whether the result is palindrome . Be careful 0 In all bases it is 0, It's palindrome number .
Code
#include<stdio.h>
void function(int N,int b)
{
if(N==0){
printf("Yes\n0");
}else{
int x[1000],count=0,m;
int flag=0;
while(N){
x[count++]=N%b;
N/=b;
}
m=count/2+1;
for(int i=0;i<m;i++){
if(x[i]!=x[count-1-i]){
flag=1;
break;
}
}
if(flag){
printf("No\n");
}else{
printf("Yes\n");
}
for(int i=count-1;i>=0;i--){
if(i!=count-1){
printf(" ");
}
printf("%d",x[i]);
}
}
}
int main()
{
int N,b;
scanf("%d%d",&N,&b);
function(N,b);
return 0;
}
边栏推荐
- Matlab finds a prime number that is greater than a given integer and follows this integer
- 先锋期货安全么?现在期货开户都是哪些流程?期货手续费怎么降低?
- [extensive reading of papers] multimodal attribute extraction
- How many questions can you answer for the interview of Mechanical Engineer?
- Programming of left-hand trapezoidal thread
- One dimensional and two dimensional array addresses
- catkin_ Make reports an error, transfers the location of the workspace, and uses other people's workspace files to cause compilation errors
- [buuctf] [actf2020 freshman competition]include
- Lfi-rce without controllable documents
- [extensive reading of papers] multi modal sarcasm detection and human classification in code mixed conversations
猜你喜欢

CCF numerical sorting (Full Score code + problem solving ideas + skill summary) 201503-2

CCF window (Full Score code + problem solving idea) March 2, 2014

JS to realize simple lottery function

PS dynamic drawing

The first dark spring cup dnuictf

CCF string matching (Full Score code + problem solving ideas + skill summary) March 3, 2014

val_ Loss decreases first and then increases or does not decrease but only increases

day02

CCF drawing (full mark code + problem solving ideas + skill summary) February 2, 2014

How to get palindrome number in MATLAB (using fliplr function)
随机推荐
Querywrapper in mybaits plus
How to realize selective screen recording for EV screen recording
[extensive reading of papers] multimodal joint attribute prediction and value extraction for e-commerce product
ThinkPHP v3.2 comment annotation injection write shell
Component communication mode
Svn password forgetting solution
Thinkphp5 log file contains trick
day02
Finding the median of two arrays by dichotomy
@PathVariable
The first dark spring cup dnuictf
Win10 one click Reset win10 to solve all system bugs without deleting any files and Applications
Error $(...) size is not a function
For loop and promise to solve the problem of concurrent callback
V3 01_ Welcome
CCF Z-scan (full mark code + problem solving ideas) 201412-2
[buuctf] [geek challenge 2019] secret file
Maximum area of islands searched
Why do high precision CNC machining centers have errors? You should pay attention to these four reasons!
Programming of left-hand trapezoidal thread