上海市计算机学会五题题解(第五期)

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;
}

完事了。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值