求指正
查看原帖
求指正
1036057
YSzita楼主2023/8/1 22:00
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,t=0,t1=0,s=0,s1=0;
    double d,d1;
    cin>>a>>b;
    for(int i=1;i<=a;i++){
    	if(i%b==0){
    		t+=i;
    		s++;
		}else{
			t1+=i;
			s1++;
		}
	}
	d=t/s;
	d1=t1/s1;
	cout<<cout<<setprecision(1)<<std::fixed<<d<<" ";
	cout<<cout<<setprecision(1)<<std::fixed<<d1;
    return 0;
}
2023/8/1 22:00
加载中...