等差数列: 以k为首相,k为公差,w个数量的和与n的大小关系 输出max(sum-0,0)
Java程序
import java.util.Scanner; public class A546 { static void run(){ Scanner in = new Scanner(System.in); int k =in.nextInt(); int n = in.nextInt(); int w = in.nextInt(); int count = 0; count = (1+w)*w*k/2; // System.out.println(count); if(count>n){ System.out.println(count-n); }else System.out.println(0); } public static void main(String[] args){ run(); } }
Python程序
def A546(): k,n,w = map(int, raw_input().split()) count = (1+w)*w*k*0.5 if count > n : print int(count -n) else: print 0 if __name__=='__main__': A546()