记录详情

Compile Error

/in/foo.cc:3:95: error: attribute(target("march=native")) is unknown
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native,march=native")
                                                                                               ^
/in/foo.cc: In function 'int read()':
/in/foo.cc:9:30: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
                       ~~~~~~~^~~~~~~

代码

#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("march=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native,march=native")
#include <bits/stdc++.h>
#define N 2000020
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
	while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return f?x:-x;
}

int pri[N], mark[N], p[N], cnt;

void shai(int n) {
  for (int i = 2; i <= n; ++ i) {
    if (!mark[i]) pri[++ cnt] = i, p[i] = i;
    for (int j = 1; j <= cnt && i * pri[j] <= n; ++ j) {
      mark[i * pri[j]] = 1;
      p[i * pri[j]] = pri[j];
    }
  }
}

int a[N], tot, bs[N], totb, cs[N];

void chai(int x) {
  while (x > 1) {
    int ps = p[x];
    x /= ps;
    a[++ tot] = ps;
  }
}

long long MAX_DFS = 0, damn;
int ans = 0, res = 0;
long long fuck[N], bbs[N];

int A;
double srt;

void dfs(int d, long long val) {
  if (val > MAX_DFS) return;
  if (d > totb) {
    if (val < A) return;
    int cpb = val;
    int cmb = damn / cpb;
    if ((cmb + cpb) & 1) {
      return;
    }
    int c = (cpb + cmb) >> 1;
    int b = (cpb - cmb) >> 1;
    if (b < A) {
      return;
    }
    ++ ans;
    res ^= (A + b) ^ c;
    // printf("Found %d %d %d\n", A, b, c);
    return;
  }
  if (val * fuck[d] < A) return;
  for (int i = 0; i <= cs[d]; ++ i) {
    dfs(d + 1, val);
    val = val * bs[d];
  }
}

int main() {
  int n = read();
  shai(2000001);
int sss=n-sqrt(((long long)n*n+1)/2);
  for (A = 2; A <= sss; ++ A) {
    // (a-1)(a+1) = (c-b)(c+b)
    damn = (long long) A * A - 1;
    tot = 0;
    chai(A - 1);
    chai(A + 1);
    MAX_DFS = n - A;
    sort(a + 1, a + tot + 1);
    totb = 0;
    for (int i = 1; i <= tot; ++ i) {
      if (a[i] != a[i - 1]) {
        bs[++ totb] = a[i];
        cs[totb] = 1;
        bbs[totb] = a[i];
      } else {
        cs[totb] ++;
        bbs[totb] *= a[i];
      }
    }
    fuck[totb + 1] = 1;
    for (int i = totb; i; -- i) {
      fuck[i] = fuck[i + 1] * bbs[i];
    }

    // if (A == 1651) {
    //   for (int i = 1; i <= totb; ++ i) {
    //     printf("%d %d %lld %lld\n", bs[i], cs[i], bbs[i], fuck[i]);
    //   }
    //   return 0;
    // }

    dfs(1, 1);
  }
  for (int i = 1; 2*i+1 <= n; ++ i) {
    ++ ans;
    res ^= (i + 1) ^ i;
  }
  printf("%d %d\n", ans, res);
}

信息

递交者
类型
递交
题目
P1003 hitwh 2019 新生赛 D Songer 的排兵布阵
语言
C++
递交时间
2020-12-17 17:15:01
评测时间
2020-12-17 17:15:01
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes