QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#59933 | #1845. Permute | Appleblue17 | WA | 355ms | 3784kb | C++14 | 1.1kb | 2022-11-02 09:35:22 | 2022-11-02 09:35:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5,mod=7;
int T,n,sav;
int c[N],sum;
int p[N],id;
int ksm(int a,int x){
int tot=1;
while(x){
if(x & 1ll) tot=tot*a%mod;
a=a*a%mod;
x>>=1ll;
}
return tot;
}
int main(){
cin>>T;
for(int T_=1;T_<=T;T_++){
sum=id=0;
for(int i=0;i<10;i++) scanf("%d",&c[i]),sum+=c[i];
if(T_==1) sav=c[0];
int lim=min(sum,6);
while(id<lim){
for(int i=0;i<10 && id<lim;i++){
if(c[i]){
c[i]--;
p[++id]=i;
}
}
}
sort(p+1,p+id+1);
int nw=0,s=0;
for(int i=0;i<10;i++){
s=(s*ksm(10,c[i])%mod+(ksm(10,c[i])+mod-1)%mod*ksm(9,mod-2)%mod*i%mod)%mod;
}
s=s*ksm(10,id)%mod;
bool fl=0;
do{
int tot=0;
for(int i=1;i<=id;i++) tot=(tot*10%mod+p[i])%mod;
if((s+tot)%mod==0){
if(sav!=1){
cout<<10+id<<'\n';
for(int i=0;i<10;i++) cout<<c[i]<<" "<<i<<'\n';
for(int i=1;i<=id;i++) cout<<1<<" "<<p[i]<<'\n';
}
fl=1;
break;
}
}while(next_permutation(p+1,p+id+1));
if(!fl){
puts("-1");
if(sav==1){
for(int i=0;i<=9;i++) cout<<c[i]<<" ";
cout<<endl;
}
}
}
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3780kb
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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2 0 0 2 0 2 2...
output:
16 1 0 0 1 1 2 0 3 0 4 0 5 0 6 0 7 2 8 0 9 1 0 1 1 1 2 1 5 1 3 1 6 16 0 0 1 1 0 2 0 3 0 4 1 5 0 6 1 7 2 8 1 9 1 0 1 1 1 4 1 5 1 6 1 3 16 1 0 1 1 1 2 0 3 0 4 1 5 0 6 1 7 2 8 2 9 1 0 1 1 1 2 1 3 1 6 1 5 16 0 0 0 1 0 2 1 3 0 4 1 5 0 6 0 7 1 8 0 9 1 0 1 1 1 5 1 3 1 7 1 8 16 0 0 0 1 1 2 1 3 0 4 1 5 0 6 0...
result:
ok T=100000
Test #4:
score: -100
Wrong Answer
time: 117ms
memory: 3644kb
input:
100000 1 3 3 2 3 0 2 1 3 2 3 1 2 0 0 3 1 0 0 1 3 2 0 2 0 2 0 1 3 1 0 1 0 3 1 1 0 3 0 2 2 2 2 3 3 3 1 0 3 0 0 3 0 2 0 3 2 0 2 3 3 0 1 1 3 3 2 1 3 1 1 2 3 0 1 2 2 0 2 3 3 1 0 3 2 0 2 3 1 0 2 1 2 3 0 2 2 3 1 2 3 3 0 3 0 0 1 1 1 1 1 3 1 0 2 1 0 3 3 3 3 0 0 3 3 2 3 3 2 1 3 3 3 1 0 2 3 0 2 3 3 3 1 3 3 2 3...
output:
-1 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 1 0 0 0 0 0 0 1 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 1 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0...
result:
wrong answer Jury has the answer but participant has not