fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. static const long long xx = 1e9+7;
  4. //nope simulation is buns time to math sob
  5. int main() {
  6. int t;
  7. cin>>t;
  8. while(t--){
  9. string x;
  10. cin>>x;
  11. bool b = true;
  12. long long int bv =0;
  13. for(char c:x){
  14. int d = int(c)-'0';
  15. if(d!=0&&d!=1){
  16. b=false;
  17. }
  18. int bb=d%2;
  19. int bv=(bv*2+bb)%xx;
  20. }
  21. long long ans = bv;
  22. if(!b){
  23. ans=(ans+1)%xx;
  24. }
  25.  
  26.  
  27. cout<<ans;
  28. }
  29. return 0;
  30. }
Success #stdin #stdout 0.01s 5284KB
stdin
1
1234567890123456789012345678901234567890
stdout
1