#include using namespace std; int main() { int K, N, F, A[1000]; int sum = 0;; cout << "粒の数: "; cin >> K; cout << "袋の数: "; cin >> N; cout << "家族の数: "; cin >> F; for (int i = 0; i < F; i++) { cout << i+1 << "人目の年齢: "; cin >> A[i]; sum += A[i]; } if (K*N >= sum) { cout << (K*N) % sum << "粒残る" << endl; } else { cout << -1 << endl; } return 0; }