#include <stdio.h> int main() { int d, coin = 0, com = 0; scanf("%d", &d); int i; for (i = 1; i <= d; i++) { int j, sum = 0; for (j = 1; j <= i; j++) { sum += j; if (i <= sum) { coin = j; break; } } com += coin; } printf("%d\n", com); return 0; }
#include <stdio.h> int main() { int d, coin = 0, com = 0; scanf("%d", &d); int i; for (i = 1; i <= d; i++) { int j, sum = 0; for (j = 1; j <= i; j++) { sum += j; if (i <= sum) { coin = j; break; } } com += coin; } printf("%d\n", com); return 0; }