当前位置:网站首页>Brush questions - Luogu -p1151 sub number integer
Brush questions - Luogu -p1151 sub number integer
2022-07-25 13:47:00 【Song Xiangshang_ UP】
P1151 A whole number of children -C Language
1、 subject

2、 The problem solving process
(1) for the first time Don't pass , Super outrageous , It's because NO Of O Lower case
result :
Code :
// Luogu P1151 A whole number of children
#include <stdio.h>
#define MIN 10000// minimum value
#define MAX 30000// Maximum
int main() {
int k;// Positive integer 0<K<1000
int sub1,sub2,sub3;
int i;
int counter=0;// Counter Solve the last line wrap problem
int temp[MAX];// Store results
scanf("%d", &k);
for (i = MIN; i <= MAX; i++) {
sub1 = i / 100;
if ((sub1 % k) != 0) {
continue;
}
sub2 = (i % 10000) / 10;
if ((sub2 % k) != 0) {
continue;
}
sub3 = i % 1000;
if ((sub3 % k) != 0) {
continue;
}
temp[counter] = i;
counter++;
/* if ((sub1 % k == 0) & (sub2 % k == 0) & (sub3 % k == 0)) { //printf("%d", i); temp[counter] = i; counter++; }*/
}
if (counter == 0) {
printf("NO");
return 0;
}
for (i = 0; i < counter; i++) {
printf("%d", temp[i]);
if (i < counter-1) {
printf("\n");
}
}
return 0;
}
(2) The second time
result :
Code :
// Luogu P1151 A whole number of children
#include <stdio.h>
#define MIN 10000// minimum value
#define MAX 30000// Maximum
int main() {
int k;// Positive integer 0<K<1000
int sub1,sub2,sub3;
int a, b, c, d, e;
int i;
int counter=0;// Counter
scanf("%d", &k);
for (i = MIN; i <= MAX; i++) {
sub1 = i / 100 ;
sub2 = (i % 10000) / 10 ;
sub3 = i % 1000 ;
if ((sub1%k == 0) & (sub2%k == 0) & (sub3%k == 0)) {
counter++;
printf("%d\n", i);
}
}
if (counter == 0) {
printf("No");
}
return 0;
}
边栏推荐
- Applet sharing function
- IM system - some common problems of message streaming
- @Wrap decorator
- Talk about your understanding of hashcode and equals methods?
- [force deduction] 1030. Arrange matrix cells in distance order
- QGIS加载在线地图:高德、天地图等
- hcip第七天笔记
- In order to improve efficiency, there are various problems when using parallelstream
- 刷题-洛谷-P1089 津津的储蓄计划
- Excel add key run macro
猜你喜欢

LabVIEW的内部错误

2022全球开发者中,你的收入排多少?
![[force buckle] 645. Wrong set](/img/0a/143d8996cbae9921652c4d4fb31046.png)
[force buckle] 645. Wrong set
Explain the precision of floating point numbers in detail

uniapp处理后台传输图片

Uncaught SyntaxError: Octal literals are not allowed in strict mode.

Uncaught SyntaxError: Octal literals are not allowed in strict mode.

VIM basic operation summary
Congestion control of TCP

The interviewer asked me: how much do you know about MySQL's storage engine?
随机推荐
JS Array indexOf includes sort() 冒号排序 快速排序 去重和随机样本 random
Excel add key run macro
Error of Tencent cloud [100007] this env is not enable anonymous login
What problems should SEOER pay attention to when baidu searches and attacks pirated websites?
刷题-洛谷-P1151 子数整数
G027-op-ins-rhel-04 RedHat openstack creates a customized qcow2 format image
Install mujoco and report an error: distutils.errors DistutilsExecError: command ‘gcc‘ failed with exit status 1
The whole process of 6w+ word recording experiment | explore the economical data storage strategy of alluxio
@Classmethod decorator
hcip第十天笔记
I2C can also be powered on by bus!
hcip第九天笔记
Hcip day 10 notes
The interviewer asked me: how much do you know about MySQL's storage engine?
mysql 01: source命令
Mujoco+spinningup for intensive learning training quick start
From input URL to web page display
What should I do if the high-level MySQL server cannot be installed and I forget the password (MySQL 8.0.29)?
剑指offer专项突击版第10天
刷题-洛谷-P1085 不高兴的津津