当前位置:网站首页>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;
}
边栏推荐
- Problèmes avec MySQL time, fuseau horaire, remplissage automatique 0
- (课设第一套)1-4 消息传递接口 (100 分)(模拟:线程)
- js 变量作用域和函数的学习笔记
- 数据库课程设计:高校教务管理系统(含代码)
- Working principle of genius telephone watch Z3
- (一)R语言入门指南——数据分析的第一步
- Pat 1097 duplication on a linked list (25 points)
- Imgcat usage experience
- (1) Introduction Guide to R language - the first step of data analysis
- Stm32f1+bc20+mqtt+freertos system is connected to Alibaba cloud to transmit temperature and humidity and control LED lights
猜你喜欢
![Intermediate use tutorial of postman [environment variables, test scripts, assertions, interface documents, etc.]](/img/b0/176bf6dea2201afc892d6750c5974b.png)
Intermediate use tutorial of postman [environment variables, test scripts, assertions, interface documents, etc.]

Office提示您的许可证不是正版弹框解决

Programming homework: educational administration management system (C language)

MySQL时间、时区、自动填充0的问题

(四)R语言的数据可视化——矩阵图、柱状图、饼图、散点图与线性回归、带状图

基于Redis的分布式锁 以及 超详细的改进思路

Unity scene jump and exit

Basic operations of databases and tables ----- modifying data tables
![[golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree](/img/6e/0802a92511ac50a652afa1678ad28c.jpg)
[golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree

dosbox第一次使用
随机推荐
2022.2.12 resumption
数据库课程设计:高校教务管理系统(含代码)
[offer18] delete the node of the linked list
基于Redis的分布式锁 以及 超详细的改进思路
Common DOS commands
Types de variables JS et transformations de type communes
Force buckle 1189 Maximum number of "balloons"
(3) Introduction to bioinformatics of R language - function, data Frame, simple DNA reading and analysis
[offer78]合并多个有序链表
MySQL performance tuning - dirty page refresh
Postman 中级使用教程【环境变量、测试脚本、断言、接口文档等】
There is no red exclamation mark after SVN update
Unity scene jump and exit
[899] ordered queue
Basic operations of databases and tables ----- modifying data tables
Derivation of logistic regression theory
Guided package method in idea
By v$rman_ backup_ job_ Oracle "bug" caused by details
[Red Treasure Book Notes simplified version] Chapter 12 BOM
Cannot change version of project facet Dynamic Web Module to 2.3.