1 条题解
-
0
C :
#include<stdio.h> int main(){ int n; double m,s=0.0; scanf("%d%lf",&n,&m); if(n<=40) s=n*m; if(n>40 && n<=50) s=40*m+(n-40)*1.5*m; if(n>50) s=40*m+15*m+(n-50)*2*m; printf("%.2f",s); return 0; }
C++ :
#include <bits/stdc++.h> using namespace std; int main(){ int i; cin>>i; double s,t,a; cin>>a; if(i <= 40){ t = i * a; }else if(i > 40 && i <= 50){ s = i - 40; t = a * 40 + a * 1.5 * s; }else if(i > 50){ s = i - 50; t = a * 40 + a * 1.5 * 10 + a * 2 * s; } cout<<fixed<<setprecision(2)<<t<<endl; return 0; }
Java :
import java.util.Scanner; public class Main{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); double m = sc.nextDouble(); double s = 0.0; if(n <= 40) { s = n * m; }else if(n <= 50 && n > 40) { s = m * 40 + (n - 40) * m * 1.5; }else if(n > 50) { s = m * 40 + 10 * m * 1.5 + (n - 50) * 2 * m; } System.out.println(String.format("%.2f",s)); } }
- 1
信息
- ID
- 2730
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者