1 #include<iostream> 2 using namespace std; 3 #include<string> 4 #include<stdio.h> 5 int main() 6 { 7 //freopen("1.txt","r",stdin); 8 int i; 9 int num; 10 int a[3] = {9 ,3 ,7}; 11 string s ; 12 cin>>num; 13 int k=0; 14 while(num--){ 15 k++; 16 cin>>s; 17 int len; 18 int mark; 19 len = s.length(); 20 int sum = 0; 21 for(i = 0; i <len ; i++) 22 if(s[len - 1 - i] != '?') 23 sum += a[(i)%3]*(s[len-1-i] - '0'); 24 else 25 mark = len - 1 - i; 26 i = 0; 27 //cout<<mark<<endl; 28 while(sum++%10 != 0 || i%a[(len-1-mark)%3]!= 0) 29 { 30 i++; 31 }; 32 33 cout<<"Scenario #"<<k<<":"<<endl; 34 //i+=20; 35 //cout<<i<<endl; 36 // cout<<mark<<endl; 37 for(int j = 0; j < len;j ++) 38 { 39 40 if(j != mark) 41 cout<<s[j]; 42 else 43 cout<<i/a[(len-1-mark)%3]; 44 } 45 cout<<endl<<endl; 46 // cout<<a[(len-1-mark)%3]<<"00000000000"<<endl; 47 //cout<<i/a[i%3]<<endl; 48 } 49 50 }