这题数据是由问题吗??

我的代码的bzoj,codevs,cogs上都AC了,为什么这里WA了所有点??

#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
 
const int maxn = 1005;
int n, d[maxn];
 
bool isprime[maxn];
int prime[maxn], tot;
void prime_table()
{
    for(int i = 2; i <= maxn; ++i) {
      if(!isprime[i]) prime[++tot] = i;
      for(int j = 1; j <= tot; ++j) {
        if(i * prime[j] <= maxn) isprime[i * prime[j]] = true;
        else break;
        if(i % prime[j] == 0) break;
      }
    }
}
 
void calc(int use[], int x, int f)
{
    for(int j = 1; j <= tot && x > 1; ++j)
      if(x % prime[j] == 0) {
        int cnt = 0;
        while(x % prime[j] == 0) ++cnt, x /= prime[j];
        use[j] += cnt * f;
      }
}
 
int main()
{
    int n, sum = 0, cnt = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
      scanf("%d", &d[i]); if(d[i] != -1) sum += d[i] - 1, ++cnt;
      if(d[i] == 0 && n != 1) printf("0"), exit(0);
    }
    if(n == 1) printf("%d\n", d[1] <= 0 ? 1 : 0), exit(0);
    if(sum > n - 2) printf("0\n"), exit(0);
    if(n == 2) printf("%d\n", 1), exit(0);
    if(cnt == n && sum != n - 2) printf("0\n"), exit(0);
    prime_table();
    int use[maxn] = {0}, t[maxn * 100] = {0}, now = 1; t[1] = 1;
    for(int i = n - 2 - sum + 1; i <= n - 2; ++i) calc(use, i, 1);
    for(int i = 1; i <= n; ++i) 
      if(d[i] > 1) for(int j = 1; j <= d[i] - 1; ++j) calc(use, j, -1);
    if(n - cnt > 1) calc(use, n - cnt, n - 2 - sum);
    for(int i = 1; i <= tot; ++i) {
      for(int j = 1; j <= use[i]; ++j) {
        int x = 0;
        for(int k = 1; k <= now; ++k) {
          (t[k] *= prime[i]) += x; x = t[k] / 10; t[k] %= 10;
        }
        t[now + 1] = x;
        while(t[now + 1] > 0) {++now; t[now + 1] = t[now] / 10; t[now] %= 10;}
      }
    }
    int a[10], Tot;
    for(int i = now; i >= 1; --i) printf("%d", t[i]);
    return 0;
} 


http://www.lydsy.com/JudgeOnline/status.php?problem_id=1005&user_id=dsl2002&language=-1&jresult=-1

0 条评论

目前还没有评论...

信息

难度
10
分类
(无)
标签
递交数
9
已通过
0
通过率
0%
上传者