QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#222338 | #5. 在线 O(1) 逆元 | ucup-team1001 | Compile Error | / | / | C++20 | 2.1kb | 2023-10-21 16:48:24 | 2023-10-21 16:48:25 |
Judging History
你现在查看的是测评时间为 2023-10-21 16:48:25 的历史记录
- [2024-11-05 21:53:59]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-10-21 16:48:25]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-10-21 16:48:24]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
#define irep(i,l,r) for(int i = (l); (i) <= (r); ++ (i))
#define ll long long
inline ll read(){
ll s = 0;
bool w = 0;
char ch = getchar();
while(! isdigit(ch)){
if(ch == '-')w = 1;
ch = getchar();
}
while(isdigit(ch)){
s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
}
return w ? -s : s;
}
string s;
int len;
int n,m;
vector<int>A,B;
vector<vector<int>>AA,BB;
void work(){
//cout << A[0] << endl ;
//irep(i, 0, m -1)cout << B[i];
//cout << endl;
string opt[10];
int optlen[10];
for(int c = 0; c < 10; ++ c){
for(int i = 0; i < m; ++ i){
int val = c * B[i];
if(val < 10)opt[c] += val + '0';
else opt[c] += (val / 10) + '0', opt[c] += (val % 10) + '0';
}
optlen[c] = opt[c].length();
// cout << opt[c] << endl;
}
int match = 0, pos = 0, ok = 0;
for(int i = 0; i < n; ++ i){
int pas = 0;
irep(ch, 0, 9){
int fl = 0;
if(i == 0 && ch == 0)continue;
for(int p = 0; p < optlen[ch]; ++ p){
if(opt[ch][p] != s[pos + p]){
fl = 1;
break;
}
}
if(fl == 0){
pos = optlen[ch] + pos;
A[i] = ch;
fl = 1, pas = 1;
break;
}
}
if(pas == 0)return;
}
AA.push_back(A);
BB.push_back(B);
}
void dfs(int x, int a0, int cur){
if(x == m){
if(B[0])work();
return;
}
int op1 = s[cur] - '0', op2 = (s[cur] - '0') * 10 + s[cur + 1] - '0';
if(op1 % a0 == 0){
B[x] = op1 / a0;
dfs(x + 1, a0, cur + 1);
}
if(op2 % a0 == 0 && op2 / a0 < 10 && op2 != 0){
B[x] = op2 / a0;
dfs(x + 1, a0, cur + 2);
}
}
void solve(){
n = read(), m = read();
A.resize(n);
B.resize(m);
AA.clear();
BB.clear();
cin >> s;
len = s.length();
if(n * m > s.length()){
puts("Impossible");
return;
}
A.push_back(0);
for(int a0 = 1; a0 < 10; ++ a0){
A[0] = a0;
B.resize(m);
dfs(0, a0, 0);
}
if(AA.size() == 0){
puts("Impossible");
return;
}else{
for(int x : AA[0])printf("%d", x);
putchar(' ');
for(int x : BB[0])printf("%d",x);
putchar('\n');
}
}
int main(){
int T = read();
while(T --){
solve();
//cout << endl;
}
}
詳細信息
implementer.cpp: In function ‘int main()’: implementer.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ /usr/bin/ld: /tmp/ccs3NaHV.o: in function `main': answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/ccRQrG5U.o:implementer.cpp:(.text.startup+0x0): first defined here /usr/bin/ld: /tmp/ccRQrG5U.o: in function `main': implementer.cpp:(.text.startup+0x153): undefined reference to `init(int)' /usr/bin/ld: implementer.cpp:(.text.startup+0x1f8): undefined reference to `inv(int)' collect2: error: ld returned 1 exit status