记录详情

Time Exceeded


  
# 状态 耗时 内存占用
#1 Accepted 2ms 2.203 MiB
#2 Time Exceeded ≥1000ms ≥168.117 MiB
#3 Wrong Answer 2ms 2.203 MiB
#4 Accepted 2ms 2.199 MiB
#5 Time Exceeded ≥1000ms ≥85.332 MiB
#6 Time Exceeded ≥1000ms ≥127.867 MiB
#7 Time Exceeded ≥1002ms ≥113.418 MiB
#8 Wrong Answer 496ms 31.801 MiB
#9 Wrong Answer 155ms 12.641 MiB
#10 Time Exceeded ≥1003ms ≥165.703 MiB

代码

#include <bits/stdc++.h>
using namespace std;
#define LL long long
const int N = 2e6 + 101; 
int n;
int num[N][21], siz[N], res[101];
int ans, ans2;

int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n; i++)
	    for(int j = i;j <= n; j+=i) 
	        num[j][++ siz[j]] = i;
	ans = (ans ^ ((1 + 1) ^ 1));ans2 = 1;
	for(int b = 2;b <= n; b++) //
	{
		int x = b - 1,y = b + 1, tot = 0;
		for(int j = 1;j <= siz[x]; j++)
		   res[++ tot] = num[x][j];
		for(int j = 1;j <= siz[y]; j++)
		   res[++ tot] = num[y][j];
		sort(res + 1,res + tot + 1);
		tot = unique(res + 1,res + tot + 1) - res;
		for(int i = 1;i <= tot; i++)
		{
			LL a1 = res[i],a2 = (LL) (b - 1) * (LL) (b + 1) / (LL) res[i], x1, x2;
			if(a1 > sqrt((LL)b * (LL)b - 1)) break;
			x1 = max(a1,a2);x2 = min(a1,a2);
			if((x1 + x2) % 2 != 0 || (x1 - x2) % 2 != 0) continue;
			LL a = (x1 - x2) / 2,c = (x1 + x2) / 2;
			if(a > b || c < b) continue;
			if(a + b + c > n) continue;
			ans = (ans ^ ((a + b) ^ c)); ++ ans2;
		}
	}
	cout << ans << ' ' << ans2 << endl;
}

信息

递交者
类型
递交
题目
P1003 hitwh 2019 新生赛 D Songer 的排兵布阵
语言
C++
递交时间
2020-12-18 16:08:48
评测时间
2020-12-18 16:08:48
评测机
分数
20
总耗时
≥5665ms
峰值内存
≥168.117 MiB