Startup and Tech
Saturday, 25 July 2020
Codeforces 546A Solution - Soldier and Bananas Solution In Java
Program
import java.util.*; public class x { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int k[] = new int[1000+1]; k[0] = sc.nextInt(); long n = sc.nextLong(); int w = sc.nextInt(); int sum = 0; long ans = 0; for(int i=1;i<=w;i++) { k[i] = k[0]*i; } for(int i=1;i<=w;i++) { sum = sum + k[i]; } ans = sum-n; if(n>sum) { System.out.println(0); } else { System.out.println(ans); } } }
Output
I/P : 3 17 4 O/P : 13
Codeforces 69A Solution - Young Physicist Solution In Java
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment