9 条题解
-
3
#include<iostream> #include<iomanip> using namespace std; int main() { double n, sum; cin >> n; if (n >= 0 && n <= 150) sum = n * 0.4463; if (n > 150 && n <= 400) sum = 150 * 0.4463 + (n - 150) * 0.4663; if (n > 400) sum = 150 * 0.4463 + 250 * 0.4663 + (n - 400) * 0.5663; cout << fixed << setprecision(1) << sum; return 0; }
-
1
CPP
#include <bits/stdc++.h> using namespace std; int main() { int i; cin>>i; if (i <= 150) { printf("%.1f",i*0.4463); } else if (i >= 151 && i <= 400) { printf("%.1f",150*0.4463+(i-150)*0.4663); } else if (i >= 401) { printf("%.1f",150*0.4463+250*0.4663+(i-400)*0.5663); } return 0; }
-
1
if
基础语句#include <bits/stdc++.h> using namespace std; int main() { int i; cin>>i; if (i <= 150) { printf("%.1f",i*0.4463); } else if (i >= 151 && i <= 400) { printf("%.1f",150*0.4463+(i-150)*0.4663); } else if (i >= 401) { printf("%.1f",150*0.4463+250*0.4663+(i-400)*0.5663); } return 0; }
-
0
#include <bits/stdc++.h> using namespace std; int main() { const double aTierUnitCost = 0.4463, bTierUnitCost = 0.4663, cTierUnitCost = 0.5663; int a; cin >> a; if(a <= 150) { cout << fixed << setprecision(1) << a * aTierUnitCost << endl; } else if(a <= 400) { cout << fixed << setprecision(1) << 150 * aTierUnitCost + (a - 150) * bTierUnitCost << endl; } else { cout << fixed << setprecision(1) << 150 * aTierUnitCost + 250 * bTierUnitCost + (a - 400) * cTierUnitCost << endl; } return 0; }
C 风格输入输出写法
#include <bits/stdc++.h> using namespace std; int main() { const double aTierUnitCost = 0.4463, bTierUnitCost = 0.4663, cTierUnitCost = 0.5663; int a; cin >> a; if(a <= 150) { printf("%.1lf", a * aTierUnitCost); } else if(a <= 400) { printf("%.1lf", 150 * aTierUnitCost + (a - 150) * bTierUnitCost); } else { printf("%.1lf", 150 * aTierUnitCost + 250 * bTierUnitCost + (a - 400) * cTierUnitCost); } return 0; }
-
-1
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; double s = 0; if(n <= 150) s = 0.4463 * n; else if(n <= 400) s = 0.4463 * 150 + (n - 150) * 0.4663; else s = 0.4463 * 150 + (400 - 150) * 0.4663 + (n - 400) * 0.5663; cout << fixed << setprecision(1) <<s; }
-
-2
#include <iostream> using namespace std; int main(){ int a=0; double b=0; cin>>a; if(a<=150){ b = a*0.4463; } else if(a>=151&&a<=400){ b += 150*0.4463; b += (a-150)*0.4663; } else{ b += 150*0.4463; b += (400-150)*0.4663; b += (a-400)*0.5663; } b=int((b*10)+0.5)/10.0; cout<<b<<endl; }
-
-3
#include <iostream> using namespace std; double cost[10005];//代表第i度电的花费 int a; double b; int main() { int i; cin>>a; for(i=1;i<=150;i++) cost[i]=0.4463; for(i=151;i<=400;i++) cost[i]=0.4663; for(i=401;i<=10000;i++) cost[i]=0.5663; for(i=1;i<=a;i++) b+=cost[i]; b=int((b*10)+0.5)/10.0; cout<<b<<endl; return 0; }
- 1
信息
- ID
- 422
- 时间
- 1000ms
- 内存
- 125MiB
- 难度
- 1
- 标签
- (无)
- 递交数
- 399
- 已通过
- 200
- 上传者