5 条题解

  • 3
    @ 2022-8-11 13:27:24

    这道题只需要使用三次 if 语句,依次判断能否整除这 33 个数,如果能就输出即可。

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int n,sum=0;
    	cin>>n;
        if(n%3==0){
            cout<<"3"<<" ";
            sum++;
        }
        if(n%5==0){
            cout<<"5"<<" ";
            sum++;
        }
        if(n%7==0){
            cout<<"7"<<" ";
            sum++;
        }
        if(sum==0) cout<<"n"<<endl;
        return 0;
    }
    
    • 0
      @ 2024-1-16 12:50:24
      #include <bits/stdc++.h>
      
      using namespace std;
      
      int main() {
      	int n;
      	cin >> n;
      	if (n % 3 == 0 && n % 5 == 0 && n % 7 == 0) {
      		cout << "3 5 7";
      	} else if (n % 3 == 0 and n % 5 == 0) {
      		cout << "3 5";
      	} else if (n % 3 == 0 and n % 7 == 0) {
      		cout << "3 7";
      	} else if (n % 5 == 0 and n % 7 == 0) {
      		cout << "5 7";
      	} else if (n % 3 == 0) {
      		cout << "3";
      	} else if (n % 5 == 0) {
      		cout << "5";
      	} else if (n % 7 == 0) {
      		cout << "7";
      	} else {
      		cout << 'n';
      	}
      	
      	return 0;
      }
      
      • 0
        @ 2023-10-22 11:23:08
        #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<<" ";
            if(n%3!=0&&n%5!=0&&n%7!=0) cout<<"n";
            return 0;
        }
        
        • 0
          @ 2023-10-1 16:36:23
          #include<iostream> 
          #include<cstdio> 
          #include<cmath> 
          #include<algorithm>
          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;
          }
          
          • @ 2024-1-16 12:51:36

            你这样太麻烦了,只要能整除它,就输出能整除的数字加空个就可以了,你看最上面的

          • @ 2024-1-16 12:51:59

            最上面那个人的

        • 0
          @ 2022-5-25 22:44:21
          #include<bits/stdc++.h>
          using namespace std;
          long long q,w,e,r,t,y,u,i,o,p,d,f,g,h,j,k,l,z,x,c,v,b,n,m;
          string s;
          long long a[100000],as[100000],asd[100000];
          char cc;
          double dd;
          int main()
          {
          	cin>>x;
          	if(x%3==0)
          	cout<<"3 ";
          	if(x%5==0)
          	cout<<"5 ";
          	if(x%7==0)
          	cout<<"7 ";
          	if(x%3!=0&&x%5!=0&&x%7!=0)
          	cout<<"n";
              return 0;
          }
          
          • 1

          信息

          ID
          6855
          时间
          1000ms
          内存
          128MiB
          难度
          1
          标签
          (无)
          递交数
          54
          已通过
          42
          上传者