当前位置:网站首页>Special palindromes of daily practice of Blue Bridge Cup
Special palindromes of daily practice of Blue Bridge Cup
2022-07-06 12:37:00 【Jing Yu】
The 13th Blue Bridge Cup individual competition and provincial competition will be held in 2022 year 4 month 9 Japan ( Saturday ) host , Take advantage of the time of winter vacation to hurry up and prepare for war . Because the blogger himself signed up for C/C++ Group , So all the updates are C/C++ Related knowledge . All the questions are the real questions of the question bank on the official website of the Blue Bridge Cup . Today is the fifth day of preparing for the battle . |
subject :
123321 It's a very special number , It's the same thing to read from the left as it is to read from the right .
Enter a positive integer n, Programming for all such five and six decimal numbers , The sum of your numbers equals n .
Input format :
The input line , Contains a positive integer n.
Output format :
Output the integers satisfying the conditions in the order of small to large , Each integer takes up one line .
The sample input :
52
Sample output :
899998
989989
998899
Data size and engagement
1<=n<=54.
Their thinking :
The number of palindromes was updated the day before , This is a special palindrome number , The solution is the same . Enter an integer first n, The sum of each digit is exactly equal to n, The title requires five and six digit output ( The first time I didn't see the title clearly, I only output five digits , Cause the test to only 20 branch ). When programming according to the requirements of the topic , You need to judge whether it is five digits or six digits in the cycle , Number of cycles i/100000 If it is equal to 0 It's five digits , Then it is to separate each one , All separated bits are added together with the input n equal , Just output this number . The output is complete after continuous loop judgment .
Complete code :
#include <stdio.h>
int main ()
{
int a,b,c,d,e,f;
int n;
scanf("%d",&n);
int i;
for(i=10000;i<999999;i++)
{
if(i/100000==0)
{
a=i%10;
b=((i-a)/10)%10;
c=((((i-a)/10)-b)/10)%10;
d=((((((i-a)/10)-b)/10)-c)/10)%10;
e=((((((((i-a)/10)-b)/10)-c)/10)-d)/10)%10;
int sum= a*10000+b*1000+c*100+d*10+e*1;
if(sum==i && a+b+c+d+e==n)
{
printf("%d\n",sum);
}
}
else
{
a=i%10;
b=((i-a)/10)%10;
c=((((i-a)/10)-b)/10)%10;
d=((((((i-a)/10)-b)/10)-c)/10)%10;
e=((((((((i-a)/10)-b)/10)-c)/10)-d)/10)%10;
f=((((((((((i-a)/10)-b)/10)-c)/10)-d)/10)-e)/10)%10;
int sum= a*100000+b*10000+c*1000+d*100+e*10+f;
if(sum==i && a+b+c+d+e+f==n)
{
printf("%d\n",sum);
}
}
}
return 0;
}
边栏推荐
- (课设第一套)1-4 消息传递接口 (100 分)(模拟:线程)
- Redis cache update strategy, cache penetration, avalanche, breakdown problems
- Vulnhub target: hacknos_ PLAYER V1.1
- Mp3mini playback module Arduino < dfrobotdfplayermini H> function explanation
- Conditional probability
- [offer18] delete the node of the linked list
- SSD technical features
- 程序设计大作业:教务管理系统(C语言)
- Office提示您的许可证不是正版弹框解决
- 1081 rational sum (20 points) points add up to total points
猜你喜欢
JS Title: input array, exchange the largest with the first element, exchange the smallest with the last element, and output array.
ES6 grammar summary -- Part I (basic)
Basic operations of databases and tables ----- classification of data
程序设计大作业:教务管理系统(C语言)
ORA-02030: can only select from fixed tables/views
Guided package method in idea
Symbolic representation of functions in deep learning papers
JS variable types and common type conversions
单片机蓝牙无线烧录
level16
随机推荐
Learning notes of JS variable scope and function
JS 函数提升和var变量的声明提升
Unity场景跳转及退出
Use of lists
Get the position of the nth occurrence of the string
idea中好用的快捷键
JUC forkjoin and completable future
The dolphin scheduler remotely executes shell scripts through the expect command
2021.11.10汇编考试
History object
Solution to the problem of automatic login in Yanshan University Campus Network
编译原理:源程序的预处理及词法分析程序的设计与实现(含代码)
SVN更新后不出现红色感叹号
[899]有序队列
idea问题记录
MySQL performance tuning - dirty page refresh
Office提示您的许可证不是正版弹框解决
Whistle+switchyomega configure web proxy
Theoretical derivation of support vector machine
JS数组常用方法的分类、理解和运用