Time Exceeded
/in/foo.cc: In function 'int main()': /in/foo.cc:25:12: warning: 'b' is used uninitialized in this function [-Wuninitialized] for(a=2; a+b+c<=n; a++) ~^~ /in/foo.cc:43:21: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized] cout<<num<<" "<<ans; ^ /in/foo.cc:25:14: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized] for(a=2; a+b+c<=n; a++) ~~~^~
代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
int a,b,c;
cin>>n;
int ans;
a=1;
int c1b;
// ans=(1+1)^1;
int num=0;
for(int b=1; a+b+b<=n; b++)
{
c=b;
if(num==0)
ans=(a+b)^c;
else
ans^=(a+b)^c;
num++;
//cout<<a<<" "<<b<<" "<<c<<endl;
}
for(a=2; a+b+c<=n; a++)
{
for(int cb=1; cb<=a*a-1; cb++) //cb=c-b
{
if(a<=b&&b<=c)
{
c1b=a*a-1/cb;
c=(c1b+cb)/2;
b=(c1b-cb)/2;
ans^=(a+b)^c;
num++;
cout<<a<<" "<<b<<" "<<c<<endl;
}
//cout<<a<<" "<<b<<" "<<c<<endl;
}
}
// cout<<a<<" "<<b<<" "<<c<<endl;
cout<<num<<" "<<ans;
}
//a^2-1=c^2-b^2;
信息
- 递交者
- 类型
- 递交
- 题目
- P1003 hitwh 2019 新生赛 D Songer 的排兵布阵
- 语言
- C++
- 递交时间
- 2020-12-18 11:10:34
- 评测时间
- 2020-12-18 11:10:34
- 评测机
- 分数
- 30
- 总耗时
- ≥7026ms
- 峰值内存
- ≥228.0 KiB