12 条题解
-
1黄子清121 (2022ts162) LV 9 @ 2023-5-8 17:15:39
#include<iostream> #include<iomanip> using namespace std; double n , x , sum ; int main(){ cin >> n; for ( int i = 1 ; i <= n ; i++ ) { cin >> x ; sum += x ; } cout<<fixed<<setprecision(4)<<sum/n<<endl; }
-
12023-4-26 18:37:00@
#include<iostream> using namespace std; int main() { int m,n; cin>>m>>n; long long sum=0; if(m%2==0) { m++; } for(int i=m;i<=n;i+=2) { sum+=i; } cout<<sum; return 0; }
-
12023-1-26 16:59:15@
#include<iostream> using namespace std; int main() { int m,n; cin>>m>>n; long long sum=0; if(m%2==0)//求>=m的最大奇数 { m++; } for(int i=m;i<=n;i+=2)//直接从>=m的最大奇数开始+=2,sum+=i; { sum+=i; } cout<<sum; return 0; }
-
-22023-4-9 11:31:18@
#include<iostream> using namespace std; int n,m,sum; int main() { cin>>n>>m; if(n%2==0) { n+=1; } for(int i=n;i<=m;i+=1) { if(i%2==1) { sum=sum+i; } } cout<<sum; return 0;
}
-
-22023-3-22 20:17:49@
#include<bits/stdc++.h> using namespace std; int m,n,ans; int main(){
cin >> m >> n; if(m%2==0){ m++; } for(int i=m;i<=n;i += 2) { ans += i; } cout<<ans; return 0;
}
-
-22022-10-29 13:50:36@
#include<iostream> using namespace std; int main(){ double m, n; cin >> m >> n; int sum = 0; for (int i = m ; i <= n ; i++) { if (i%2 ==1) { sum +=i; } } cout << sum << endl; return 0; }
-
-22022-10-1 16:32:34@
我们知道一个数当它被按位与时,会变成大于等于,离最近的奇数。 所以可得AC Code:
#include <iostream> #include <cstdio> using namespace std; int main() { int n, m; scanf("%d %d", &n, &m); n |= 1; //变成 >=n的最近奇数 int ans = 0; while (n <= m) { ans += n; n += 2; } cout << ans; return 0; }
-
-32022-10-31 15:16:24@
#include<iostream> #include<stdio.h> using namespace std; int main(){ int n,m,a=0; cin>>n>>m; for(int i=n;i<=m;i++){ if(i%2==1)a+=i; } printf("%d",a); }
-
-32022-9-13 17:31:13@
#include <bits/stdc++.h> using namespace std; int main(void) { int qs1, qs2; int all; cin >> qs1 >> qs2; int m = qs1 % 2; int n = qs2 % 2; if (qs1 != qs2) { if (m == 0) { qs1 = qs1 + 1; } if (n == 0) { qs2 -= 1; } if (qs1 == qs2) { all = qs1; } else { for (qs1 = qs1, qs2 = qs2; qs1 < qs2; qs1 += 2) { all = all + qs1; } all += qs1; } } else if (qs1 == qs2) { if (n == 0, m == 0) { all = 0; } if (n != 0, m != 0) { all = qs1 = qs2; } } cout << all; return 0; }
-
-32022-2-25 21:53:02@
#include <stdio.h>
#include <math.h>
int main(void)
{
int qs1 = 0, qs2 = 0; int all = 0; scanf("%d%d", &qs1, &qs2); int m = qs1 % 2; int n = qs2 % 2; if (qs1 != qs2) { if (m == 0) { qs1 = qs1 + 1; } if (n == 0) { qs2 -= 1; } if (qs1 == qs2) { all = qs1; } else { for (qs1 = qs1, qs2 = qs2; qs1 < qs2; qs1 += 2) { all = all + qs1; } all += qs1; } } else if (qs1 == qs2) { if (n == 0, m == 0) { all = 0; } if (n != 0, m != 0) { all = qs1 = qs2; } } printf("%d", all); return 0;
}
-
-92022-1-8 9:44:31@
#include <stdio.h> #include <iostream> using namespace std; int main() { double l,r; cin >> l >> r; int sum = 0; for (int i = l; i <= r ;i++ ) { if(i%2 == 1) { sum += i; } } cout <<sum <<endl; }
-
-142022-1-8 9:43:38@
#include <stdio.h> #include <iostream> using namespace std; int main() { double l,r; cin >> l >> r; int sum = 0; for(int i = l ; i <= r ; i++) { if(i%2 ==1) { sum +=i; } } cout << sum << endl; }
- 1
信息
- ID
- 928
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 5
- 标签
- 递交数
- 1312
- 已通过
- 488
- 上传者