hexuchen @ 2023-05-07 12:53:51
为什么全错 QWQ
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,k,sum=0,sum2=0,wei,wei2;
double a,b;
scanf("%d %d",&n,&k);
for(int i=1;i<=n;i++){
if(i%k==0){
wei++;
sum+=i;
}
else{
wei2++;
sum2+=i;
}
}
a=double(sum)/wei;
b=double(sum2)/wei2;
printf("%.1lf %.1lf",a,b);
return 0;
}
by _buzhidao_ @ 2023-05-07 13:00:44
#include<iostream>
using namespace std;
long int a,b,e,f;
double c,d;
int main(){
cin>>a>>b;
for(int i=1;i<=a;i++){
if(i%b==0){
c+=i;
e+=1;
}
else{
d+=i;
f+=1;
}
}
c/=e;d/=f;
printf("%.1lf",c);
cout<<' ';
printf("%.1lf",d);
return 0;
}
by Eleveslaine @ 2023-05-07 13:07:15
@hexuchen wei,wei2 没有初始化为
by Eleveslaine @ 2023-05-07 13:07:51
@buzhidao 别人求助你发个自己代码有啥用啊
by _buzhidao_ @ 2023-05-07 13:13:42
@Franz_Liszt 那题解写代码有什么用啊
by __er @ 2023-05-07 13:16:35
@buzhidao 题解有思路,你没有思路有什么用啊
by __er @ 2023-05-07 13:17:13
那是对思路的实现,你是什么啊?
动不动甩个代码显得您架子很大?
by _buzhidao_ @ 2023-05-07 13:26:48
@__er 我懒不行吗?
by _buzhidao_ @ 2023-05-07 13:27:19
@__er 多管闲事
by __er @ 2023-05-07 13:28:19
@buzhidao 没那个闲工夫建议别看
by _buzhidao_ @ 2023-05-07 13:29:41
@__er 我可不想吵架