QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#59932 | #1845. Permute | Appleblue17 | WA | 2ms | 3708kb | C++14 | 1.1kb | 2022-11-02 09:34:47 | 2022-11-02 09:34:49 |
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[1];
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;
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3708kb
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:
-1 0 999999994 0 0 0 0 0 0 0 0
result:
wrong answer Jury has the answer but participant has not