当前位置:网站首页>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;
}
边栏推荐
- @Autowired 和 @Resource 的区别
- Redis 缓存更新策略,缓存穿透、雪崩、击穿问题
- JS function promotion and declaration promotion of VaR variable
- 2021.11.10汇编考试
- Learning notes of JS variable scope and function
- NRF24L01 troubleshooting
- InnoDB dirty page refresh mechanism checkpoint in MySQL
- [leetcode19] delete the penultimate node in the linked list
- Arduino JSON data information parsing
- 单片机蓝牙无线烧录
猜你喜欢

Programming homework: educational administration management system (C language)

Problèmes avec MySQL time, fuseau horaire, remplissage automatique 0

JS 函数提升和var变量的声明提升

First use of dosbox

Esp8266 connect onenet (old mqtt mode)

JS function promotion and declaration promotion of VaR variable

idea中好用的快捷键

Vulnhub target: hacknos_ PLAYER V1.1
![[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

C programming exercise
随机推荐
By v$rman_ backup_ job_ Oracle "bug" caused by details
MySQL时间、时区、自动填充0的问题
Unity3D制作注册登录界面,并实现场景跳转
Flink late data processing (3)
There is no red exclamation mark after SVN update
PT OSC deadlock analysis
基于Redis的分布式ID生成器
Basic operations of databases and tables ----- classification of data
MySQL占用内存过大解决方案
Lock wait timeout exceeded try restarting transaction
Page performance optimization of video scene
Basic operations of databases and tables ----- creating data tables
VIM command line notes
Force buckle 1189 Maximum number of "balloons"
Programming homework: educational administration management system (C language)
JS变量类型以及常用类型转换
Working principle of genius telephone watch Z3
[Leetcode15]三数之和
Idea problem record
[Nodejs] 20. Koa2 onion ring model ----- code demonstration