QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#494301 | #5003. Etched Emerald Orbs | Ink_bai | WA | 0ms | 3692kb | C++14 | 1.2kb | 2024-07-27 15:07:32 | 2024-07-27 15:07:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned long long
#define int long long
#define endl '\n'
const int N = 1e4 + 5;
typedef pair<int, int> PII;
#define MAX LONG_LONG_MAX
int a[N], b[N], c[N];
void solve()
{
uint k, x;
cin >> k;
if (k % 2 == 0)
{
cout << -1 << endl;
return;
}
x = (k + 1) / 2;
cout << x << " ";
int idx = 1;
while (k)
{
a[idx++] = k % 10;
k /= 10;
}
int lena = idx - 1; // 每个部分都很清楚
idx = 1;
while (x)
{
b[idx++] = x % 10;
x /= 10;
}
int lenb = idx - 1;
int i, j;
for (i = 1; i <= lenb; i++)
for (j = 1; j <= lena; j++)
c[i + j - 1] += a[j] * b[i];
for (i = 1; i < lena + lenb; i++)
if (c[i] > 9)
{
c[i + 1] += c[i] / 10;
c[i] %= 10;
}
int len = len = lena + lenb;
while (c[len] == 0 && len > 1)
len--;
for (i = len; i >= 1; i--)
cout << c[i];
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3632kb
input:
5
output:
3 15
result:
ok single line: '3 15'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
7
output:
4 28
result:
ok single line: '4 28'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3648kb
input:
2625
output:
1313 3446625
result:
wrong answer 1st lines differ - expected: '2415 2875', found: '1313 3446625'