标签:class turn span head sam sample for long 贪心
10
30
#include<bits/stdc++.h> #include <math.h> using namespace std; typedef long long ll; inline int read() { int x=0,f=1;char ch=getchar(); while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();} while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();} return x*f; } const int maxn=200001; const int inf=0x3f3f3f3f; const int mod=1e9+7; int a[maxn]; int n; int sum; void inint(){ cin>>n; sum=n; } int main(){ inint(); if(n==1){ printf("0"); return 0; } if(n==2){ printf("0"); return 0; } if(n==3){ printf("2"); return 0; } if(n==4){ printf("3"); return 0; } int p=0; for(int i=2;i<n;i++){ if(sum<i){ break; } a[p++]=i; sum-=i; } while(sum>0){ for(int j=p-1;j>=0;j--){ if(sum>0){ a[j]++; sum--; } else{ break; } } } ll z=1; for(int i=0;i<=p-1;i++){ z=z*a[i]; } printf("%lld",z); }
标签:class turn span head sam sample for long 贪心
原文地址:https://www.cnblogs.com/lipu123/p/12828936.html