QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#305854#7695. Double UpGauravMTL 1ms3916kbC++203.1kb2024-01-16 04:34:492024-01-16 04:34:49

Judging History

你现在查看的是最新测评结果

  • [2024-01-16 04:34:49]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3916kb
  • [2024-01-16 04:34:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define ll long long int
#define endl '\n'
 #define pb push_back
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;



double squareRoot(double number, int precision)
{
    int start = 0, end = number;
    int mid;
 
    // variable to store the answer
    float ans;
 
    // for computing integral part
    // of square root of number
    while (start <= end) {
        mid = (start + end) / 2;
        if (mid * mid == number) {
            ans = mid;
            break;
        }
 
        // incrementing start if integral
        // part lies on right side of the mid
        if (mid * mid < number) {
            start = mid + 1;
            ans = mid;
        }
 
        // decrementing end if integral part
        // lies on the left side of the mid
        else {
            end = mid - 1;
        }
    }
 
    // For computing the fractional part
    // of square root upto given precision
    float increment = 0.1;
    for (int i = 0; i < precision; i++) {
        while (ans * ans <= number) {
            ans += increment;
        }
 
        // loop terminates when ans * ans > number
        ans = ans - increment;
        increment = increment / 10;
    }
    return ans;
}
string dbl(string &s)
{
    string ans;
    ll car=0;
    for(int i=s.length()-1;i>-1;i--)
    {
        ll num=s[i]-'0';
        ans.pb((num*2+car)%10+'0');
        car=(num*2+car)/10;
        
    }
    if(car)
    {
        ans.pb(car+'0');
    }
    reverse(ans.begin(),ans.end());
    return ans;
}
void solve()
{
   ll t;
  // cin>>t;
  t=1;
   while(t--)
   {
       ll n;
       vector<string>a;
       cin>>n;
       string tmp;
       for(int i=0;i<n;i++)
       {
           
           cin>>tmp;
           a.pb(tmp);
       }
      sort(a.begin(),a.end());
      vector<int>cnt(150,0);
      string s="1";
      ll ind=0;
      for(int i=0;i<n;i++)
      {
        //  cout<<a[i]<<" ";
          while(a[i]!=s)
          {
              s=dbl(s);
              ind++;
          }
          if(a[i]==s)
          {
              cnt[ind]++;
          }
           
      }
      ll mx=-1;
      for(int i=0;i<149;i++)
      {
          if(cnt[i])
          {
              mx=i;
          }
          cnt[i+1]+=cnt[i]/2;
      }
    //   string tst="8";
    //   cout<<dbl(tst)<<endl;
      if(mx==-1)
      {
          cout<<0<<endl;
      }
      else
      {
          while(ind<mx)
          {
              s=dbl(s);
              ind++;
          }
          cout<<s<<endl;
      }
       
   }
    
}




int main() {


// #ifndef ONLINE_JUDGE
//     freopen("lostcow.in", "r", stdin);
//     freopen("lostcow.out", "w", stdout);
// #endif

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3672kb

input:

5
4 2 2 1 8

output:

16

result:

ok single line: '16'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3740kb

input:

1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

512

result:

ok single line: '512'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3768kb

input:

1000
1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650...

output:

649037107316853453566312041152512

result:

ok single line: '649037107316853453566312041152512'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

1
1

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

1
2

output:

2

result:

ok single line: '2'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3916kb

input:

1
4294967296

output:

4294967296

result:

ok single line: '4294967296'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

1
18446744073709551616

output:

18446744073709551616

result:

ok single line: '18446744073709551616'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

1
1267650600228229401496703205376

output:

1267650600228229401496703205376

result:

ok single line: '1267650600228229401496703205376'

Test #9:

score: -100
Time Limit Exceeded

input:

384
18014398509481984 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 10737418...

output:


result: