QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#484037 | #9107. Zayin and Count | PetroTarnavskyi# | AC ✓ | 24ms | 3600kb | C++20 | 1.3kb | 2024-07-19 15:33:22 | 2024-07-19 15:33:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
void solve()
{
map<int, int> m1, m2;
int cnt1 = 0;
int cnt2 = 0;
FOR (i, 0, 10)
{
int a;
cin >> a;
if (a)
{
m1[i] = cnt1;
cnt1++;
}
}
bool is_zer = false;
FOR (i, 0, 10)
{
int a;
cin >> a;
if (a)
{
if (i == 0)
is_zer = 1;
m2[cnt2] = i;
cnt2++;
}
}
__int128 x = 0;
string s;
cin >> s;
reverse(ALL(s));
__int128 pw = 1;
FOR (i, 0, SZ(s))
{
int d = s[i] - '0';
x += pw * m1[d] + (i == 0 || m1.count(0) ? 0 : pw);
pw *= cnt1;
}
string res = "";
int i = 0;
while (x)
{
if (!is_zer && i)
x--;
int d = x % cnt2;
res += ('0' + m2[d]);
x /= cnt2;
i++;
}
reverse(ALL(res));
if (res.empty())
res += ('0' + m2[0]);
cout << res << '\n';
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 24ms
memory: 3600kb
input:
10000 1 0 0 0 1 1 0 0 0 1 0 0 1 0 1 1 1 1 0 0 950595954440050004054505054050 1 0 0 0 1 1 1 1 0 0 1 1 1 0 1 0 0 0 1 1 45467007076660767550460064 1 1 1 1 0 0 0 1 0 0 1 1 0 1 1 0 1 0 0 1 23373171320213300170200722 0 0 0 0 1 1 1 0 1 0 0 0 1 0 0 1 0 1 1 1 558565664666565565558468668484 1 1 0 0 1 0 1 0 1 ...
output:
52755244567262766742575722 41990991999414091249949 101364364636933104003903 57558888789255872922852552 757222758857875785288225787822 761161760076076167101117776167 56666586555668686566656586856566686658 15611661611611111511116116661611616155 505885888775005550558080707878 3912911219633669993999199 ...
result:
ok 10000 lines