萌新一个,请问大佬们还有更加简洁高效的方法吗?QAQ

B2043 判断能否被 3,5,7 整除

~~压行~~
by Fze_8 @ 2023-06-06 18:28:17


[第二篇题解](https://www.luogu.com.cn/blog/over-knee-socks/solution-b2043)
by H_Kaguya @ 2023-06-06 18:28:19


```cpp #include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; if(n%3==0) cout<<"3 "; if(n%5==0) cout<<"5 "; if(n%7==0) cout<<"7 "; return 0; } ```
by AnOIer @ 2023-07-11 07:00:13


```c #include <stdio.h> #include <stack> #include <queue> #include <vector> #include <list> #include <map> using namespace std; int a; bool flag = true; int main(){ scanf("%d" , &a); if(a % 3 == 0){ printf("3 "); flag = false; } if(a % 5 == 0){ printf("5 "); flag = false; } if(a % 7 == 0){ printf("7 "); flag = false; } if(flag) printf("n"); return 0; }
by printf_ @ 2023-07-17 17:39:05


没必要导入那么多头文件
by xieyzy @ 2023-07-31 15:57:11


``` #include<bits/stdc++.h> using namespace std; int x,f=0; int main(){ cin>>x; if(x%3==0){ f=1;//如果x能被整除那么f+1,f用来判断三个条件的成立 cout<<"3 "; } if(x%5==0){ f=1; cout<<"5 ";//if判断是从小到大比的,不需要比大小 } if(x%7==0){ f=1; cout<<"7 "; } if(f==0){//三个条件都没成立,f就=0 输出n; cout<<"n"; } return 0; } ```
by Tairitsu_Cat @ 2023-08-12 17:26:07


循环应该可以做吧?``` #include<iostream> using namespace std; long long n,m; int main() { cin>>n; if(n%3==0&&n%5==0&&n%7==0){ printf("%d %d %d",3, 5 ,7); }else if(n%3==0&&n%5==0){ printf("%d %d",3,5); }else if(n%3==0&&n%7==0){ printf("%d %d",3,7); }else{ printf("%d %d",5,7); } return 0; } ```
by jiangjialeqaz @ 2023-08-16 21:53:26


|