liaojiaze7_2 @ 2024-12-04 17:16:12
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
long long cnt=1;
cin>>n;
int a=n,b=n;
while( n!=0 ) {
while( n!=0 ) {
cnt*=n;
n--;
}
}
for( int i=1 ; i<=a ; i++ ) {
cnt+=i;
}
cout<<cnt-b;
return 0;
}
by _lxc__ @ 2024-12-04 17:18:44
用高精度
by _Vistion_ @ 2024-12-04 17:18:47
50的阶乘用int???
得学高精度
by YJC_____ @ 2024-12-07 16:55:24
@liaojiaze7_2
#include<bits/stdc++.h>
using namespace std;
int n,x;
int sum=0;
int pd(int y) {
for(int i=2; i*i<=y; ++i) {
if(y%i==0) return 0;
}
return 1;
}
int main() {
scanf("%d",&n);
if(n<2) {
printf("0\n");
return 0;
} else if(n==2) {
printf("2\n1\n");
return 0;
}
for(int i=2; i<=n; ++i) {
if(i%2==0&&i!=2) continue;
if(sum+i>n) {
printf("%d\n",x);
return 0;
}
if(pd(i)) {
printf("%d\n",i);
sum+=i;
x++;
}
}
return 0;
}
用这个