#include using namespace std; typedef long long LL; /** * 功能:计算约数个数 * @param n * @return */ LL getDivisorCount(LL x) { unordered_map primes; //key:质数 value:个数 //求质数因子 for (int i = 2; i <= x / i; i++) while (x % i == 0) x /= i, primes[i]++; //primes[i]表示质数i因子的个数+1 //如果还有质数,那就加上 if (x > 1) primes[x]++; //公式大法 LL res = 1; for (auto p: primes) res = res * (p.second + 1); return res; } LL res; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cout << i << " " << getDivisorCount(i) << endl; return 0; }