4 条题解

  • 2
    @ 2025-2-6 1:32:10

    第一反应:if 秒了;

    第二反应:嗯?好像秒不了;

    第三反应:if + bool 秒了。

    上代码:

    #include <bits/stdc++.h>
    using namespace std;
    int x;
    bool b;
    int main() {
    	cin >> x;
    	if (x % 3 == 0) {
    		cout << "3 ";
    		b = 1;
    	} if (x % 5 == 0) {
    		cout << "5 ";
    		b = 1;
    	} if (x % 7 == 0) {
    		cout << "7 ";
    		b = 1;
    	} if (b == 0) cout << 'n';
    	return 0;
    }
    
    • 1

      #include<bits/stdc++.h> using namespace std; int main() { int x; cin>>x; if(x%30 && x%50 && x%70) { cout<<3<<" "<<5<<" "<<7<<endl; exit(0); } else if(x%150 || x%210 || x%350) { if(x%150) { cout<<3<<" "<<5<<endl; exit(0); } if(x%210) { cout<<3<<" "<<7<<endl; exit(0); } if(x%350) { cout<<5<<" "<<7<<endl; exit(0); } } else if(x%30 || x%50 || x%70) { if(x%30) { cout<<3<<endl; exit(0); } if(x%50) { cout<<5<<endl; exit(0); } if(x%7==0) { cout<<7<<endl; exit(0); } } else { cout<<"n"<<endl; } return 0; } 如有大冤种看到,请自主换行。

      • 0

        #include <bits/stdc++.h> using namespace std; int x; bool b; int main() { cin >> x;

        if (x % 3 == 0) {
        	cout << "3 ";
        	b = 1;
        } if (x % 5 == 0) {
        	cout << "5 ";
        	b = 1;
        } if (x % 7 == 0) {
        	cout << "7 ";
        	b = 1;
        } if (b == 0) cout << 'n';
        return 0;
        

        }

        • 0
          @ 2024-12-12 18:53:25

          #include<bits/stdc++.h> using namespace std; int main(){ int a,b,c,d; cin>>a; b=a%3; c=a%5; d=a%7; if (b0 and c0 and d0) {cout<<3<<" "<<5<<" "<<7;} else if (b0 and c0) {cout<<3<<" "<<5;} else if (b0 and d0) {cout<<3<<" "<<7;} else if (d0 and c0) {cout<<5<<" "<<7;} else if (b0) {cout<<3;} else if (c0) {cout<<5;} else if (d0) {cout<<7;} else {cout<<"n";} return 0; } //自己换行

          • 1

          信息

          ID
          4493
          时间
          1000ms
          内存
          512MiB
          难度
          1
          标签
          (无)
          递交数
          98
          已通过
          71
          上传者