YouTube video link : click here Question link : click here
Solution : in Java
import java.util.Scanner;
public class SoldierandBananas {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int k = sc.nextInt();
int n = sc.nextInt();
int w = sc.nextInt();
int res = (k*((w*(w+1))/2))-n;
if(res<0){
System.out.println(0);
}else{
System.out.println(res);
}
}
}
______________________________________________
Thanks for visiting
0 Comments