18 条题解

  • 0
    @ 2025-4-20 13:10:52

    #include #include #include

    using namespace std;

    int main() { int n; cin >> n; vector divisors;

    if (n % 3 == 0) divisors.push_back(3);
    if (n % 5 == 0) divisors.push_back(5);
    if (n % 7 == 0) divisors.push_back(7);
    
    sort(divisors.begin(), divisors.end());
    
    if (divisors.empty()) {
        cout << 'n' << endl;
    } else {
        for (int d : divisors) {
            cout << d << endl;
        }
    }
    
    return 0;
    

    }

    • 0
      @ 2023-3-18 21:48:30
      #include<iostream>
      #include<iomanip> 
      using namespace std;
      int main()
      {
      	int a;
      	cin>>a;
      	if(a%3==0 && a%5==0 && a%7==0)
      	{
      		cout<<"3 5 7";
      	}
      	else if(a%3==0 && a%5==0)
      	{
      		cout<<"3 5";
      	}
      	else if(a%3==0 && a%7==0)
      	{
      		cout<<"3 7";
      	}
      	else if(a%5==0 && a%7==0)
      	{
      		cout<<"5 7";
      	}
      	else if(a%3 ==0)
      	{
      		cout<<"3";
      	}
      	else if(a%5 ==0)
      	{
      		cout<<"5";
      	}
      	else if(a%7 ==0)
      	{
      		cout<<"7";
      	}
      	else
      	cout<<"n";
      	return 0;
      }
      
    • -1
      @ 2024-12-11 13:57:45
      n = int(input())
      if n % 3 != 0 and n % 5 != 0 and n % 7 != 0:
          print('n')
          exit(0)
      else:
          if n % 3 == 0:
              print('3 ', end = '')
          if n % 5 == 0:
              print('5 ', end = '')
          if n % 7 == 0:
              print('7 ', end = '')
      exit(0)
      
      • -1
        @ 2024-4-26 21:41:40
        #include <iostream>
        #include <cstdio>
        #include <fstream>
        #include <cmath>
        #include <deque>
        #include <vector>
        #include <queue>
        #include <string>
        #include <cstring>
        #include <map>
        #include <stack>
        #include <set> 
        using namespace std;
        int main()
        {
            int a;
        	cin>>a;
        	if(a%3==0 && a%5==0 && a%7==0)
        	{
        		cout<<"3 5 7";
        	}
        	else if(a%3==0 && a%5==0)
        	{
        		cout<<"3 5";
        	}
        	else if(a%3==0 && a%7==0)
        	{
        		cout<<"3 7";
        	}
        	else if(a%5==0 && a%7==0)
        	{
        		cout<<"5 7";
        	}
        	else if(a%3 ==0)
        	{
        		cout<<"3";
        	}
        	else if(a%5 ==0)
        	{
        		cout<<"5";
        	}
        	else if(a%7 ==0)
        	{
        		cout<<"7";
        	}
        	else
        	cout<<"n";
        }
        
        • -1
          @ 2021-12-8 20:36:00

          补一个Python代码

          a=int(input())
          b=False
          if a%3==0:
              print(3,end=" ")
              b=True;
          if a%5==0:
              print(5,end=" ")
              b=True;
          if a%7==0:
              print(7,end=" ")
              b=True;
          if not b:
              print("n")
          
        • -2
          @ 2024-8-25 8:55:22
          #include<bits/stdc++.h>
          using namespace std;
          const int N=1e5+10;
          int main(){
          	long long a;
          	cin>>a;
          	if(a%3==0){
          		cout<<"3"<<" ";
          		if(a%5==0){
          			cout<<"5"<<" ";
          			if(a%7==0){
          				cout<<"7"<<" ";
          			}
          		}
          		if(a%7==0){
          			cout<<"7"<<" ";
          		}
          	}
          	else if(a%5==0){
          		cout<<"5"<<" ";
          		if(a%7==0){
          			cout<<"7"<<" ";
          		}
          	}
          	else if(a%7==0){
          		cout<<"7"<<" ";
          	}
          	if(a%3!=0&&a%5!=0&&a%7!=0){
          		cout<<"n";
          	}
          	return 0;
          }
          

          90分,哪错了???

          • -2
            @ 2024-4-26 21:44:45

            头文件有点多,有点复杂(上网查的),点个关注再走吧! 求求了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

            #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int a; cin>>a; if(a%30 && a%50 && a%70) { cout<<"3 5 7"; } else if(a%30 && a%50) { cout<<"3 5"; } else if(a%30 && a%70) { cout<<"3 7"; } else if(a%50 && a%7==0) { cout<<"5 7"; } else if(a%3 ==0) { cout<<"3"; } else if(a%5 ==0) { cout<<"5"; } else if(a%7 ==0) { cout<<"7"; } else cout<<"n"; }

            
            
            • @ 2024-10-23 20:10:09

              直接用头文件<bits/stdc++.h>

          • -2
            @ 2023-12-24 12:07:51

            #include using namespace std; const int N=1e3+10; const int INF=0x3f3f3f3f; int a; int main(){ cin>>a; if(a%30&&a%50&&a%70) cout<<"3 5 7"; else if((a%30&&a%50)) cout<<"3 5"; else if(a%30&&a%70) cout<<"3 7"; else if(a%70&&a%50) cout<<"5 7"; else if(a%30) cout<<"3"; else if(a%50) cout<<"5"; else if(a%70) cout<<"7"; else cout<<"n"; } 笨蛋做法

            • -2
              @ 2023-5-11 18:08:05

              #include

              using namespace std;

              int main()

              {

              int a;

              cin>>a;

              if(a%30&&a%50&&a%7==0)

              { cout<<3<<" "<<5<<" "<<7;

              }

              else if(a%30&&a%50)

              {

              cout<<3<<" "<<5;

              }

              else if(a%30&&a%70)

              {

              cout<<3<<" "<<7;

              }

              else if(a%50&&a%70)

              {

              cout<<5<<" "<<7;

              }

              else if(a%3==0)

              {

              cout<<3;

              }

              else if(a%5==0)

              {

              cout<<5;

              }

              else if(a%7==0)

              {

              cout<<7;

              }

              else

              {

              cout<<"n";

              }

              return 0;

              }

              • -2
                @ 2022-7-2 20:36:35

                #include<stdio.h> #include using namespace std; int main() { int n; cin>>n; if((n%30)&&(n%50)&&(n%70)) { cout<<3<<" "<<5<<" "<<7<<endl; }else if((n%30)&&(n%50)&&(n%7!=0)) { cout<<3<<" "<<5<<endl; }else if((n%30)&&(n%5!=0)&&(n%70)) { cout<<3<<" "<<7<<endl; }else if((n%3!=0)&&(n%50)&&(n%70)) { cout<<5<<" "<<7<<endl; }else if((n%30)&&(n%5!=0)&&(n%7!=0)) { cout<<3<<endl; }else if((n%3!=0)&&(n%50)&&(n%7!=0)) { cout<<5<<endl; }else if((n%3!=0)&&(n%5!=0)&&(n%70)) { cout<<7<<endl; }else { cout<<"n"<<endl; } }

                • -2
                  @ 2022-5-1 17:03:43

                  #include using namespace std; int main() { int a; cin >> a; if(a % 3 == 0 && a % 5 == 0 && a % 7 == 0) { cout << "3" << ' ' << "5" << ' ' << "7" << ' '; } if(a % 3 == 0 && a % 5 == 0) { cout << "3" << ' ' << "5" << ' ' ; } if(a % 3 == 0 && a % 7 == 0) { cout << "3" << ' ' << "7" << ' ' ; } if(a % 5 == 0 && a % 7 == 0) { cout << "5" << ' ' << "7" << ' ' ; } if(a % 3 == 0) { cout << "3" << ' ' ; } if(a % 5 == 0) { cout << "5" << ' ' ; } if(a % 7 == 0) { cout << "7" <<' ' ; } if(a % 3 != 0 && a % 5 != 0 && a % 7 != 0) { cout << n; } return 0; }

                  • -2
                    @ 2022-3-30 22:01:34

                    #include

                    using namespace std;

                    int main(){

                    int a,b,c,d;
                    
                    cin>>a;
                    
                    if(a%3==0) {
                    
                    cout<<"3"<<" ";
                    
                    d=1;	
                    }
                    
                    if(a%5==0) {
                    
                    cout<<"5"<<" ";
                    
                    d=1;	
                    
                    }
                    
                    
                    if(a%7==0) {
                    
                    cout<<"7"<<" ";
                    
                    d=1;	
                    
                    }
                    if(d!=1) cout<<"n";
                    

                    }

                    • -2
                      @ 2022-2-9 11:28:24

                      #include <stdio.h> int main() { int n; scanf("%d", &n); bool a = false;

                      if (n % 3 == 0) {
                          printf("%d ", 3);
                          a = true;
                      }
                      
                      if (n % 5 == 0) {
                          printf("%d ", 5);
                          a = true;
                      }
                      
                      if (n % 7 == 0) {
                          printf("%d ", 7);
                          a = true;
                      }
                      
                      if (!a)
                          printf("n");
                      

                      }

                      • -3
                        @ 2024-9-3 21:12:08
                        #include<bits/stdc++.h>
                        using namespace std;
                        const int N=1e5+10;
                        int main(){
                        	long long a;
                        	cin>>a;
                        	if(a%3==0){
                        		cout<<"3"<<" ";
                        		if(a%5==0){
                        			cout<<"5"<<" ";
                        			if(a%7==0){
                        				cout<<"7"<<" ";
                        			}
                        		}
                        		if(a%7==0){
                        			cout<<"7"<<" ";
                        		}
                        	}
                        	else if(a%5==0){
                        		cout<<"5"<<" ";
                        		if(a%7==0){
                        			cout<<"7"<<" ";
                        		}
                        	}
                        	else if(a%7==0){
                        		cout<<"7"<<" ";
                        	}
                        	if(a%3!=0&&a%5!=0&&a%7!=0){
                        		cout<<"n";
                        	}
                        	return 0;
                        }
                        
                        • -3
                          @ 2021-10-20 13:48:44
                          • a = int(input())
                          • if a % 3 == 0 and a % 5 != 0 and a % 7 != 0:
                          • print("3")
                          • if a % 5 == 0 and a % 3 !=0 and a % 7 != 0:
                          • print("5")
                          • if a % 7 == 0 and a % 3 !=0 and a % 5 != 0:
                          • print("7")
                          • if a % 3 == 0 and a % 5 == 0 and a % 7 != 0:
                          • print("3 5")
                          • if a % 3 == 0 and a % 7 == 0 and a % 5 != 0:
                          • print("3 7")
                          • if a % 5 == 0 and a % 7 == 0 and a % 3 !=0:
                          • print("5 7")
                          • if a % 3 == 0 and a % 5 == 0 and a % 7 == 0:
                          • print("3 5 7")
                          • if a % 3 != 0 and a % 5 != 0 and a % 7 != 0:
                          • print("n")
                          • -4
                            @ 2021-12-4 12:42:50

                            各位的题解都这么复杂? 最简题解(目前):

                            #include <stdio.h>
                            int main() {
                                int n;
                                scanf("%d", &n);
                                bool a = false;
                            
                                if (n % 3 == 0) {
                                    printf("%d ", 3);
                                    a = true;
                                }
                            
                                if (n % 5 == 0) {
                                    printf("%d ", 5);
                                    a = true;
                                }
                            
                                if (n % 7 == 0) {
                                    printf("%d ", 7);
                                    a = true;
                                }
                            
                                if (!a)
                                    printf("n");
                            
                            }
                            

                            其中的a用于判断是否无法被任何数输出。

                            • -4
                              @ 2021-10-20 13:36:31

                              hhh a = int(input()) if a % 3 == 0 and a % 5 != 0 and a % 7 != 0: print("3") if a % 5 == 0 and a % 3 !=0 and a % 7 != 0: print("5") if a % 7 == 0 and a % 3 !=0 and a % 5 != 0: print("7") if a % 3 == 0 and a % 5 == 0 and a % 7 != 0: print("3 5") if a % 3 == 0 and a % 7 == 0 and a % 5 != 0: print("3 7") if a % 5 == 0 and a % 7 == 0 and a % 3 !=0: print("5 7") if a % 3 == 0 and a % 5 == 0 and a % 7 == 0: print("3 5 7") if a % 3 != 0 and a % 5 != 0 and a % 7 != 0: print("n")

                              • -5
                                @ 2021-10-20 13:36:10

                                a = int(input()) if a % 3 == 0 and a % 5 != 0 and a % 7 != 0: print("3") if a % 5 == 0 and a % 3 !=0 and a % 7 != 0: print("5") if a % 7 == 0 and a % 3 !=0 and a % 5 != 0: print("7") if a % 3 == 0 and a % 5 == 0 and a % 7 != 0: print("3 5") if a % 3 == 0 and a % 7 == 0 and a % 5 != 0: print("3 7") if a % 5 == 0 and a % 7 == 0 and a % 3 !=0: print("5 7") if a % 3 == 0 and a % 5 == 0 and a % 7 == 0: print("3 5 7") if a % 3 != 0 and a % 5 != 0 and a % 7 != 0: print("n")

                                • 1

                                信息

                                ID
                                864
                                时间
                                1000ms
                                内存
                                128MiB
                                难度
                                6
                                标签
                                递交数
                                1229
                                已通过
                                359
                                上传者