1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#include <iostream> using namespace std; int main() { long int T, i, N; unsigned long long p, sum; scanf("%ld", &T); for (i = 0; i < T; i++) { scanf("%ld\n", &N); sum = 0; p = (N - 1) / 3; sum = ((3 * p*(p + 1)) / 2); p = (N - 1) / 5; sum = sum + ((5 * p*(p + 1)) / 2); p = (N - 1) / 15; sum = sum - ((15 * p*(p + 1)) / 2); printf("%lld\n", sum); } return 0; } |