Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
21138 xingru 判断能否被3,5,7整除 C++ 通过 0 MS 240 KB 926 2023-06-23 15:12:40

Tests(1/1):


#include<bits/stdc++.h> using namespace std; int main(){ int a,n; cin>>a; if(a%3==0) n=1; if(a%5==0) n=2; if(a%7==0) n=3; if((a%3==0)&&(a%5==0)) n=4; if((a%3==0)&&(a%7==0)) n=5; if((a%5==0)&&(a%7==0)) n=6; if((a%3==0)&&(a%5==0)&&(a%7==0)) n=7; switch(n) { case 1: cout<<"3"<<endl; break; case 2: cout<<"5"<<endl; break; case 3: cout<<"7"<<endl; break; case 4: cout<<"3 5"<<endl; break; case 5: cout<<"3 7"<<endl; break; case 6: cout<<"5 7"<<endl; break; case 7: cout<<"3 5 7"<<endl; break; default: cout<<n<<endl; } return 0; }


测评信息: