当前位置:网站首页>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;
}
边栏推荐
- CCF call auction (full mark code + problem solving ideas + skill summary) 201412 - 3
- Shangpinhui knowledge points of large e-commerce projects
- Querywrapper in mybaits plus
- Examples of bubble sorting and matrix element screening in MATLAB
- Steps for commissioning of vertical machining center
- Lfi-rce without controllable documents
- Database connection to company database denied
- V3 02——What‘s new in Chrome extensions
- CCF elimination games (Full Score code + problem solving ideas + skill summary) February 2, 2015
- jsPlumb. Deleteeveryconnection is not a function & jsplumb clear canvas jsplumb delete all nodes and all connections
猜你喜欢
![[buuctf] [actf2020 freshman competition]exec1](/img/af/22051a5feb3c1f6d7201a483bde127.jpg)
[buuctf] [actf2020 freshman competition]exec1

CCF drawing (full mark code + problem solving ideas + skill summary) February 2, 2014
[email protected][])"/>NoViableAltException([email protected][])

PS dynamic drawing

Component communication mode

Matlab function for limit, definite integral, first-order derivative, second-order derivative (classic examples)

Thinkphp5 log file contains trick

August 24, 2021 deque queue and stack

Matlab construction operation example
![[buuctf] [actf2020 freshman competition]include](/img/42/50439290177fdea5f431e315cac1a1.jpg)
[buuctf] [actf2020 freshman competition]include
随机推荐
1066 root of AVL tree (25 points)
高清机械原理 · 机械设计经典动图
August 24, 2021 deque queue and stack
Double pointer circular linked list
Computer screenshot how to cut the mouse in
Error $(...) size is not a function
How to realize selective screen recording for EV screen recording
V3_ Chrome extended Chinese translation document V3 directory
2021-05-12
Matlab calculates the factorial sum of the first n numbers (easy to understand)
CCF window (Full Score code + problem solving idea) March 2, 2014
KnightCTF WEB
[extensive reading of papers] attributes guided facial image completion
数控加工中心打刀缸工作原理及故障处理
2021-08-05 leetcode notes
这种零件该怎么编程加工?
Distributed -- openresty+lua+redis
PS tip: the video frame to Layer command cannot be completed because dynamiclink is not available
CCF image rotation (Full Score code + problem solving idea) 201503-01
[extensive reading of papers] multimodal joint attribute prediction and value extraction for e-commerce product