maguangyin @ 2024-12-02 12:51:47
#include <bits/stdc++.h>
using namespace std;
int main ()
{
int n,k,a,e=0,r=0;
float m,c,s=0,t=0;
cin>>n>>k;
for (int i=1;i<=n;i++)
{
a=i;
if(a%k==0)
{
s+=a;
e++;
}
else if(a%k!=0)
{
t+=a;
r++;
}
}
m=s/e;
c=t/r;
cout<<fixed<<setprecision(1)<<m<<' '<<c;
return 0;
}
by maguangyin @ 2024-12-02 12:52:30
到底哪错了啊
by pjh0625 @ 2024-12-02 12:55:57
我的代码:
# include <bits/stdc++.h>
using namespace std;
int n, k, sum;
int main () {
scanf ("%d%d", &n, &k);
for (int i = k; i <= n; i += k)
sum += i;
printf ("%.1f ", double (sum) / (n / k));
sum = (1 + n) * n / 2 - sum;
printf ("%.1f\n", double (sum) / (n - n / k));
return 0;
}
@maguangyin 你这代码有种说不出的怪
by zhaochenjin @ 2024-12-06 21:18:14
我也看着很怪,很乱