QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#490873 | #8632. 算式密码锁 | KiharaTouma# | 65 | 3ms | 3948kb | C++23 | 1.3kb | 2024-07-25 16:37:09 | 2024-07-25 16:37:10 |
Judging History
answer
//qoj8632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
char s[6][23];
int calc(int a, int b, int c, int d, int e, int f){
int x = s[0][a] - '0', y = s[2][c] - '0', z = (s[4][e] - '0') * 10 + s[5][f] - '0';
int le = 0, ri = z;
if(s[1][b] == '+'){
le = x + y;
} else if(s[1][b] == '-'){
le = x - y;
} else if(s[1][b] == '*'){
le = x * y;
} else {
while(1);
if(y == 0 || x % y != 0){
return 0;
}
le = x / y;
}
if(s[3][d] == '='){
return (le == ri) ? 1 : 0;
} else if(s[3][d] == '<'){
return (le < ri) ? 1 : 0;
} else {
return (le > ri) ? 1 : 0;
}
}
int main(){
scanf("%d", &n);
scanf("%s", s[0]);
scanf("%s", s[1]);
scanf("%s", s[2]);
scanf("%s", s[3]);
scanf("%s", s[4]);
scanf("%s", s[5]);
for(int i = 0; i <= 5; ++ i){
for(int j = 0; j < n; ++ j){
s[i][j+n] = s[i][j];
}
}
int ans = 0;
for(int b = 0; b < n; ++ b){
for(int c = 0; c < n; ++ c){
for(int d = 0; d < n; ++ d){
for(int e = 0; e < n; ++ e){
for(int f = 0; f < n; ++ f){
int cnt = 0;
for(int i = 0; i < n; ++ i){
cnt += calc(0+i, b+i, c+i, d+i, e+i, f+i);
}
ans = max(ans, cnt);
}
}
}
}
}
printf("%d\n", ans);
return 0;
}
詳細信息
Pretests
Final Tests
Test #1:
score: 5
Accepted
time: 0ms
memory: 3868kb
input:
1 7 + 9 = 1 6
output:
1
result:
ok single line: '1'
Test #2:
score: 5
Accepted
time: 0ms
memory: 3868kb
input:
1 3 + 8 = 4 5
output:
0
result:
ok single line: '0'
Test #3:
score: 5
Accepted
time: 0ms
memory: 3868kb
input:
1 8 + 8 < 1 5
output:
0
result:
ok single line: '0'
Test #4:
score: 5
Accepted
time: 0ms
memory: 3864kb
input:
1 5 + 6 > 1 0
output:
1
result:
ok single line: '1'
Test #5:
score: 5
Accepted
time: 0ms
memory: 3756kb
input:
1 2 * 8 = 1 6
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Time Limit Exceeded
input:
1 8 / 3 = 0 2
output:
result:
Test #7:
score: 0
Time Limit Exceeded
input:
1 9 / 6 > 0 1
output:
result:
Test #8:
score: 5
Accepted
time: 0ms
memory: 3876kb
input:
1 7 - 7 > 7 4
output:
0
result:
ok single line: '0'
Test #9:
score: 5
Accepted
time: 0ms
memory: 3752kb
input:
1 5 + 2 < 0 9
output:
1
result:
ok single line: '1'
Test #10:
score: 5
Accepted
time: 0ms
memory: 3856kb
input:
2 32 ++ 47 == 10 06
output:
2
result:
ok single line: '2'
Test #11:
score: 5
Accepted
time: 0ms
memory: 3948kb
input:
2 15 ++ 41 == 70 61
output:
1
result:
ok single line: '1'
Test #12:
score: 5
Accepted
time: 3ms
memory: 3864kb
input:
10 5063152515 ++++++++++ 3643427729 ========== 1729333612 7714289416
output:
1
result:
ok single line: '1'
Test #13:
score: 5
Accepted
time: 0ms
memory: 3752kb
input:
10 5699749655 ++++++++++ 4486705309 ========== 0690847717 9735641858
output:
3
result:
ok single line: '3'
Test #14:
score: 5
Accepted
time: 2ms
memory: 3856kb
input:
10 1672370904 ++++++++++ 8835825976 ><><=><<<< 7640932128 5621497720
output:
8
result:
ok single line: '8'
Test #15:
score: 5
Accepted
time: 3ms
memory: 3804kb
input:
10 1458060574 ++++++++++ 6380400163 =>>><>>=>= 7765073124 7628127469
output:
3
result:
ok single line: '3'
Test #16:
score: 0
Time Limit Exceeded
input:
10 2709586364 /---*/+/++ 9992425165 ========== 4129100709 2377293095
output:
result:
Test #17:
score: 0
Time Limit Exceeded
input:
10 7209588823 */*+*-++-* 6913916311 ========== 5186517243 4256032489
output:
result:
Test #18:
score: 0
Time Limit Exceeded
input:
8 74122886 -*/**+/* 44018012 >==<>>=< 04336845 12552226
output:
result:
Test #19:
score: 0
Time Limit Exceeded
input:
9 362285771 ---++*+// 894616931 <==<><<=< 770556473 084205441
output:
result:
Test #20:
score: 0
Time Limit Exceeded
input:
10 4263385446 +-*-++++*/ 8152614990 >>==<>===< 4536040292 8354005890