Nick801102 @ 2022-06-01 21:09:59
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k,a1=0,a2=0,b1=0,b2=0,s=0;
double a3,b3;
for(int i=k;i<=n;i+=k)
{
a1+=n;
a2++;
}
a3=a1/a2;
printf("%0.1f",a3);
cout<<" ";
for(int i=1;i<=n;i++)s+=i;
b1=s-a1;
b2=n-a2;
b3=b1/b2;
printf("%0.1f",b3);
return 0;
}
5个RE。
by ajahjahah @ 2022-06-01 21:11:34
输入呢?
先测样例再提交
by tangrunxi @ 2022-06-01 21:14:43
@Nick801102 您是不是忘记输入了
by Nick801102 @ 2022-06-06 19:36:42
SB的我~~~~~~~~
但真的大无语~~~第2个到第4个全WA...... 艹TM
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k,a1=0,a2=0,b1=0,b2=0,s=0;
double a3,b3;
cin>>n>>k;
for(int i=k;i<=n;i+=k)
{
a1+=i;
a2++;
}
a3=a1/a2;
printf("%0.1f",a3);
cout<<" ";
for(int i=1;i<=n;i++)s+=i;
b1=s-a1;
b2=n-a2;
b3=b1/b2;
printf("%0.1f",b3);
return 0;
}
啊———————————————————
by mayangsu1106 @ 2022-08-19 18:16:44
为什么不直接统计两类的总数和个数呢
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;
double sum1=0,sum2=0,t1=0,t2=0;
cin>>n>>k;
for(int i=1;i<=n;i++){
if(i%k==0){
sum1+=i;
t1++;
}else{
sum2+=i;
t2++;
}
}
printf("%0.1f%.1lf",sum1/t1,sum2/t2);
return 0;
}
by mayangsu1106 @ 2022-08-19 18:17:49
AC代码
by Nick801102 @ 2022-08-20 09:38:21
谢谢