QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#629102 | #1845. Permute | light_ink_dots | RE | 0ms | 3764kb | C++20 | 985b | 2024-10-11 03:54:21 | 2024-10-11 03:54:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int iv9=4;
int T,m,now,flg;
int c[10],p[10];
int pow10(int n){//10^n mod 7
int res=1;
for(int i=1;i<=n%6;i++)
res=10*res%7;
return res;
}
int main(){
scanf("%d",&T);
int f=T>10;
int cs=0;
while(T--){
cs++;
m=now=flg=0;
for(int i=0;i<=9;i++)
scanf("%d",&c[i]);
if(f){
if(cs!=13)
continue;
for(int i=0;i<=9;i++)
scanf("%d%c",c[i],i==9? '\n':' ');
}
for(int i=0;i<=9&&m<8;i++)
while(m<8&&c[i])
c[i]--,p[++m]=i;
for(int i=0;i<=9;i++){
int v=pow10(c[i]);
now=(now*v+(v-1)*iv9*i)%7;
}
now=now*pow10(m)%7;
do{
int cur=now;
for(int i=1;i<=m;i++)
cur=(cur*10+p[i])%7;
if(cur==0){
flg=1,printf("%d\n",10+m);
for(int i=0;i<=9;i++)
printf("%d %d\n",c[i],i);
for(int i=1;i<=m;i++)
printf("1 %d\n",p[i]);
break;
}
}while(next_permutation(p+1,p+1+m));
if(flg==0)
puts("-1");
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3764kb
input:
3 0 1 0 0 1 0 0 0 0 0 0 2 0 0 0 0 1 0 0 1 0 1000000000 0 0 0 0 0 0 0 0
output:
12 0 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 1 1 4 14 0 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1 1 1 1 1 6 1 9 -1
result:
ok T=3
Test #2:
score: -100
Runtime Error
input:
100000 0 0 0 1 0 1 1 1 0 1 1 1 0 0 1 0 1 0 1 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 1 0 1 0 1 0 0 1 0 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0 1 1 1 0 1 1 1 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 0 1 1 0 0 1 0 0 1 1 0 1 0 0 1 0 1 1 0 0 1 0 0 0 0 1 0 0 0 1 1 1 1 1 1 1 0 1 1 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 1...