题目大意:已知n个数的平均值m以及前n-1个数,请问第n个数是多少?
#include <stdio.h> int n, m, i, j, k, s; int main(){ scanf("%d", &n); for(i=1; i<n; i++){ scanf("%d", &k); s += k; } scanf("%d", &m); printf("%lld\n", (long long)m*n-s); return 0; }
题目大意:已知n个数的平均值m以及前n-1个数,请问第n个数是多少?
#include <stdio.h> int n, m, i, j, k, s; int main(){ scanf("%d", &n); for(i=1; i<n; i++){ scanf("%d", &k); s += k; } scanf("%d", &m); printf("%lld\n", (long long)m*n-s); return 0; }