| 1 |
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; long long s(long long n) { return n * (n+1) / 2; } int main() { int T; scanf("%d", &T); while(T--) { long long N; scanf("%lld", &N); N--; printf("%lld ", s(N/3)*3 + s(N/5)*5 - s(N/15)*15); } return 0; } T = int(input()) for i in range(T): N = int(input()) a, b, s = 1, 2, 0 while b <= N: if b%2 == 0: s += b a, b = b, a + b print(s) using System; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) { int T = Convert.ToInt32(Console.ReadLine()); while(T-- > 0) { long N = Convert.ToInt64(Console.ReadLine()); long p = 1, f; for (f = 2; f*f <= N; ++f) while (N % f == 0) { p = f; N /= f; } if (N > 1) p = N; Console.WriteLine(p); } } } |
Комментарии