标签:iostream 自然数 tchar 情况 bre 有一个 type head utc
2
1
这个题就是爆了ll,所以要用用__int128
void scan(__int128 &x) { //输入 x = 0; int f = 1; char ch; if((ch = getchar()) == ‘-‘) f = -f; else x = x*10 + ch-‘0‘; while((ch = getchar()) >= ‘0‘ && ch <= ‘9‘) x = x*10 + ch-‘0‘; x *= f; } void _print(__int128 x) { if(x > 9) _print(x/10); putchar(x%10 + ‘0‘); } void print(__int128 x) { //输出 if(x < 0) { x = -x; putchar(‘-‘); } _print(x); }
#pragma GCC optimize(2) #include<cstdio> #include<iostream> #include<algorithm> #include<map> #include<string> #include <math.h> #include<memory.h> #include<cstring> using namespace std; typedef unsigned long long ll; void scan(__int128 &x) { //输入 x = 0; int f = 1; char ch; if((ch = getchar()) == ‘-‘) f = -f; else x = x*10 + ch-‘0‘; while((ch = getchar()) >= ‘0‘ && ch <= ‘9‘) x = x*10 + ch-‘0‘; x *= f; } void _print(__int128 x) { if(x > 9) _print(x/10); putchar(x%10 + ‘0‘); } void print(__int128 x) { //输出 if(x < 0) { x = -x; putchar(‘-‘); } _print(x); } const int maxn=3e3+100; int biaoji[maxn]; int p[maxn]; int cnt=0; void inint(){ for(int i=2;i<=maxn;i++){ if(!biaoji[i]){ p[++cnt]=i; } for(int j=1;j<=cnt&&i*p[j]<maxn;j++){ biaoji[i*p[j]]=1; if(i%p[j]==0){ break; } } } } int n; __int128 f[maxn]; void c(){ cin>>n; f[0]=1; } int main(){ inint(); c(); for(int i=1;i<=cnt;i++){ for(int j=p[i];j<=n;j++){ f[j]+=f[j-p[i]]; } } print(f[n]); }
标签:iostream 自然数 tchar 情况 bre 有一个 type head utc
原文地址:https://www.cnblogs.com/lipu123/p/13515024.html