当前位置:网站首页>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;
}
边栏推荐
- Knowledge summary of request
- Idea problem record
- [899]有序队列
- Symbolic representation of functions in deep learning papers
- Easy to use shortcut keys in idea
- MySQL takes up too much memory solution
- Problèmes avec MySQL time, fuseau horaire, remplissage automatique 0
- [golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree
- Game 280 weekly
- js题目:输入数组,最大的与第一个元素交换,最小的与最后一个元素交换,输出数组。
猜你喜欢
Basic operations of databases and tables ----- creating data tables
单片机蓝牙无线烧录
Unity3d makes the registration login interface and realizes the scene jump
dosbox第一次使用
There is no red exclamation mark after SVN update
JS function promotion and declaration promotion of VaR variable
基于Redis的分布式锁 以及 超详细的改进思路
Basic operations of databases and tables ----- view data tables
Redis based distributed ID generator
Arduino uno R3 register writing method (1) -- pin level state change
随机推荐
Basic operations of databases and tables ----- modifying data tables
MySQL时间、时区、自动填充0的问题
About using @controller in gateway
Unity场景跳转及退出
[Nodejs] 20. Koa2 onion ring model ----- code demonstration
idea中导包方法
(课设第一套)1-4 消息传递接口 (100 分)(模拟:线程)
HCIP Day 12
记一次云服务器被密码爆破的经历——关小黑屋、改密码、改端口
js 变量作用域和函数的学习笔记
Esp8266 connects to bafayun (TCP maker cloud) through Arduino IED
MySQL占用内存过大解决方案
First use of dosbox
[leetcode622]设计循环队列
Solution to the problem of automatic login in Yanshan University Campus Network
[899]有序队列
Design and implementation of general interface open platform - (39) simple and crude implementation of API services
(4) Data visualization of R language -- matrix chart, histogram, pie chart, scatter chart, linear regression and strip chart
Theoretical derivation of support vector machine
Expected value (EV)