版本比较
数论专题
正文
增加 7 行删除 7 行
27 行未改动28293031323334353624 行未改动6162636465666768697071727374757677787980818262 行未改动1451461471481491501511521535 行未改动15916016116216316416516627 行未改动$\log_2(x) + \log_2(y)=\log_2(x \times y),\log_2(5) + \log_2(4)=\log_2(20)$## 阶乘### 阶乘规律定义:$n!=1 \times 2 \times 3 \dots \times n$常见:$10!=3628800$24 行未改动using namespace std;# define N 100005double n;int t;double E = 2.718281828459045, PI = 3.14159263589793;int W[] = {1, 1, 1, 1, 2, 3, 3, 4, 5};int main () {while (~scanf ("%d", &t)) {n = t;if (n <= 8) printf ("%d\n", W[t]);else printf("%.0lf\n", floor (n * log10(n / E) + 0.5 * log10(2 * PI * n)) + 1);}return 0;}```62 行未改动double H = 0, G = 1, A = 0, Q = 0;int n, x;int main () {cin >> n;for (int i = 1; i <= n; i ++) {cin >> x;H = H + 1.0 / x;5 行未改动G = pow (G, 1.0 / n);A = A / n;Q = sqrt (Q / n);printf ("%.2lf %.2lf %.2lf %.2lf", H, G, A, Q);return 0;}```27 行未改动28293031323334353624 行未改动6162636465666768697071727374757677787980818262 行未改动1451461471481491501511521535 行未改动15916016116216316416516627 行未改动$\log_2(x) + \log_2(y)=\log_2(x \times y),\log_2(5) + \log_2(4)=\log_2(20)$## 阶乘### 阶乘规律定义:$n!=1 \times 2 \times 3 \dots \times n$常见:$10!=3628800$24 行未改动using namespace std;# define N 100005double n;int t;double E = 2.718281828459045, PI = 3.14159263589793;int W[] = {1, 1, 1, 1, 2, 3, 3, 4, 5};int main () {while (~scanf ("%d", &t)) {n = t;if (n <= 8) printf ("%d\n", W[t]);else printf("%.0lf\n", floor (n * log10(n / E) + 0.5 * log10(2 * PI * n)) + 1);}return 0;}```62 行未改动double H = 0, G = 1, A = 0, Q = 0;int n, x;int main () {cin >> n;for (int i = 1; i <= n; i ++) {cin >> x;H = H + 1.0 / x;5 行未改动G = pow (G, 1.0 / n);A = A / n;Q = sqrt (Q / n);printf ("%.2lf %.2lf %.2lf %.2lf", H, G, A, Q);return 0;}```