1.正规数的判定
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n;
cin>>n;
while(n%2==0){
n/=2;
}
while(n%3==0){
n/=3;
}
while(n%5==0){
n/=5;
}
if(n==1){
cout<<"Regular Number";
}else{
cout<<"Irregular Number";
}
return 0;
}
2.最大平方因子
#include<iostream>
using namespace std;
int main(){
int n,t;
cin>>n;
for(int i=1;i<=n;i++){
if(n%i==0){
for(int j=1;j*j<=i;j++){
if(j*j==i){
t=i;
}
}
}
}
cout<<t;
return 0;
}
3.汽水兑奖
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,s,s1,s2,t;
cin>>a>>b>>c;
s1=s2=s=a;
while(s1/b!=0||s2/c!=0){
t=s1/b+s2/c;
s1%=b;
s2%=c;
s+=t;
s1+=t;
s2+=t;
}
cout<<s;
return 0;
}
4.戴口罩
#include<iostream>
using namespace std;
int main() {
int n,t=10,day=0;
cin>>n;
while(true) {
if(t==n) {
break;
} else if(day%7==5||day%7==6) {
t+=7;
}
t--;
day++;
}
cout<<day;
return 0;
}
5.多边形的判定
#include <iostream>
using namespace std;
int main() {
int n;
long long sum = 0;
int ma = 0;
cin >> n;
for (int i = 0; i < n; i++) {
int t;
scanf("%d", &t);
sum += t;
if (t>ma) ma=t;
}
if (ma < sum - ma) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
}
完事了。