QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#225305 | #4932. Moon and Sun | Rabeya# | WA | 1ms | 3568kb | C++17 | 1.7kb | 2023-10-24 14:17:42 | 2023-10-24 14:17:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef unordered_map<int,int> umap;
typedef long double ld;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define popcount __builtin_popcount
#define case cout<<"Case "<<__testcase-testcase<<": ";
#define endl '\n'
#define inf 1e9
ll a[100500],b[100500];
ll gcd(ll a,ll b, ll& x,ll& y)
{
if(b==0)
{
x=1,y=0;
return a;
}
ll x1,y1;
ll d=gcd(b,a%b,x1,y1);
x=y1;
y=x1-y1*(a/b);
return d;
}
bool f(ll a,ll b,ll c,ll& x0,ll&y0, ll& g)
{
g=gcd(abs(a),abs(b),x0,y0);
if(c%g)
return false;
x0*=c/g;
y0*=c/g;
if(a<0)x0=-x0;
if(b<0)y0=-y0;
return true;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int testcase=1;
//cin>>testcase;
int __testcase=testcase;
while(testcase--){
int n,i;
cin>>n;
ll x=n-1,y=1,sum=0,g;
ll z=-1;
if(n%2)
z=1;
b[0]=1*z;
for(int i=0;i<n;i++){
cin>>a[i];
if(i!=0)
{
b[i]=(b[i-1]*x*(-1))/y;
x--;
y++;
}
sum+=a[i]*b[i];
}
ll cnt=0,m=235813,l=-100000,r=100000;
for(i=0;i<n;i++)
{
f(b[i],-m,-(sum-(b[i]*a[i])),x,y,g);
x=abs(x)%m;
if((x<=r&&x!=a[i])||(x-m>=l&&x-m!=a[i]))
cnt++;
}
cout<<cnt<<endl;
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3496kb
input:
5 4 1 0 7 2
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
4 10 20 30 -40
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
2 100 100
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
16 19 43 69 21 72 9 70 -15 25 29 -23 -13 -41 79 -89 93
output:
14
result:
ok single line: '14'
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3448kb
input:
392 23531 -70064 22423 -55534 23391 -22700 88756 80526 36369 -10007 -28096 22617 -12591 80476 39531 -80144 -87955 93969 33358 30633 34132 -65817 -57922 -28367 -74214 50143 -36912 21570 -27256 -34989 14043 -92315 -12277 26859 97682 91797 -79591 30563 -58224 27016 -67737 99067 30626 16374 -49340 -1712...
output:
358
result:
wrong answer 1st lines differ - expected: '334', found: '358'