QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#602526#8723. 乘二UESTC_DECAYALI#RE 0ms3792kbC++201.2kb2024-10-01 10:16:512024-10-01 10:16:53

Judging History

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

  • [2024-10-01 10:16:53]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3792kb
  • [2024-10-01 10:16:51]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#define RI register int
#define CI const int&
using namespace std;
const int N=200005,mod=1e9+7;
int n,k; vector <int> vec[30];
inline int quick_pow(int x,int p=mod-2,int mul=1)
{
    for (;p;p>>=1,x=1LL*x*x%mod) if (p&1) mul=1LL*mul*x%mod; return mul;
}
int main()
{
    scanf("%d%d",&n,&k);
    for (RI i=1;i<=n;++i)
    {
        int x; scanf("%d",&x);
        vec[32-__builtin_clz(x)].push_back(x);
    }
    for (RI i=0;i<30;++i)
    {
        sort(vec[i].begin(),vec[i].end());
        if ((int)vec[i].size()==n)
        {
            int d=k/n,r=k%n,sum=0;
            for (RI j=0;j<r;++j)
            (sum+=1LL*vec[i][j]%mod*quick_pow(2,d+1)%mod)%=mod;
            for (RI j=r;j<n;++j)
            (sum+=1LL*vec[i][j]%mod*quick_pow(2,d)%mod)%=mod;
            return printf("%d",sum),0;
        }
        for (auto &x:vec[i])
        {
            if (k==0)
            {
                int sum=0;
                for (RI j=0;j<30;++j)
                for (auto x:vec[j]) (sum+=x%mod)%=mod;
                return printf("%d",sum),0;
            }
            --k; vec[i+1].push_back(x<<1); x=0;
        }
        vec[i].clear();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3792kb

input:

3 3
7 2 1

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: -100
Runtime Error

input:

200000 1605067
366760624 67854 93901 693975 27016 1046 10808 6533158 54778 500941023 77236442 32173 10431454 2 9726 1553148 89282 411182309 494073 131299543 249904771 7906930 353 9909 3632698 29156 1917186 303 737 1189004 22 1983 263 711 4106258 2070 36704 12524642 5192 123 2061 22887 66 380 1 10153...

output:


result: