1 solutions
-
0
C :
#include<stdio.h> int main() { int x; scanf("%d",&x); if(x==1) printf("%.1lf",5.0); if(x>=2&&x<=5) printf("%.1lf",4.5*x); if(x>=6&&x<=10) printf("%.1lf",4.0*x); if(x>10) printf("%.1lf",3.5*x); return 0; }
C++ :
#include<bits/stdc++.h> using namespace std; int main(){ int n; double r; cin>>n; if(n == 1){ r = 5; }else if(n >= 2 && n <= 5){ r = n * 4.5; }else if(n >= 6 && n <= 10){ r = n * 4; }else if(n > 10){ r = n * 3.5; } cout<<fixed<<setprecision(1)<<r; }
Java :
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int x = sc.nextInt(); double a = x*5.0; double b = x*4.5; double c = x*4.0; double d = x*3.5; if(x>10) { System.out.println(d); }else if(x>=6) { System.out.println(c); }else if(x>=2) { System.out.println(b); }else { System.out.println(a); } } }
Python :
n = int(input()) if n == 1: p = 5 elif 2 <= n <= 5: p = 4.5 elif 6 <= n <= 10: p = 4 else: p=3.5 print("%.1f" % (n*p))
- 1
Information
- ID
- 10560
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By