QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#329402 | #4932. Moon and Sun | ouo# | WA | 1ms | 3788kb | C++14 | 1.3kb | 2024-02-16 17:09:46 | 2024-02-16 17:09:47 |
Judging History
answer
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 235813;
vector<int> generateNthRowPascalTriangle(int n)
{
vector<int> nthRow;
nthRow.push_back(1);
for (int i = 1; i <= n - 1; ++i)
{
vector<int> temp = nthRow;
for (int j = 1; j < i; ++j)
{
nthRow[j] = temp[j - 1] + temp[j];
}
nthRow.push_back(1);
}
return nthRow;
}
int main()
{
int n;
int hot = 0;
cin >> n;
vector<int> nthRow = generateNthRowPascalTriangle(n);
vector<int> data(n);
vector<long long> m(n);
long long sum_ = 0;
for (int i = 0; i < n; i++)
{
cin >> data[i];
m[i] = data[i] * nthRow[i];
if (i != 0)
m[i] *= -1;
sum_ += m[i];
}
for (int i = 0; i < n; i++)
{
if ((((sum_ - m[i]) % MOD) % nthRow[i] == 0 && (-1e6 <= ((sum_ - m[i]) % MOD) / nthRow[i] <= 1e6) ||
((((sum_ - m[i]) % MOD) + MOD) % nthRow[i] == 0 && -1e6 <= (((sum_ - m[i]) % MOD) + MOD) / nthRow[i] <= 1e6) ||
((((sum_ - m[i]) % MOD) - MOD) % nthRow[i] == 0 && -1e6 <= (((sum_ - m[i]) % MOD) - MOD) / nthRow[i] <= 1e6)))
{
hot += 1;
}
}
cout << hot << endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3468kb
input:
5 4 1 0 7 2
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3788kb
input:
4 10 20 30 -40
output:
4
result:
ok single line: '4'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3520kb
input:
2 100 100
output:
2
result:
wrong answer 1st lines differ - expected: '0', found: '2'