QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#351211#5460. Sum of NumbersHappyNewDayWA 14ms4240kbC++142.0kb2024-03-11 18:41:322024-03-11 18:41:33

Judging History

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

  • [2024-03-11 18:41:33]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:4240kb
  • [2024-03-11 18:41:32]
  • 提交

answer

#include <bits/stdc++.h>
#define Fst first
#define Snd second
#define MP make_pair
#define ll long long
#define PII pair<int,int>
#define PIL pair<int,ll>
#define PLI pair<ll,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
#define lint vector<int>
using namespace std;
int tac,n,m;
string s;
char str[200010];
bool operator < (lint x,lint y)
{
    if (x.size()!=y.size()) return x.size()<y.size();
    for (int i=(int)x.size()-1;i>=0;i--) if (x[i]!=y[i]) return x[i]<y[i];
    return 0;
}
bool operator > (lint x,lint y)
{
    if (x.size()!=y.size()) return x.size()>y.size();
    for (int i=(int)x.size()-1;i>=0;i--) if (x[i]!=y[i]) return x[i]>y[i];
    return 0;
}
lint operator + (lint x,lint y)
{
    if (x.size()<y.size()) swap(x,y);
    for (int i=0;i<y.size();i++) x[i]+=y[i];
    for (int i=0;i<(int)x.size()-1;i++) x[i+1]+=x[i]/10,x[i]%=10;
    if (!x.empty() && x.back()>=10) x.push_back(x.back()/10),x[(int)x.size()-2]%=10;
    return x;
}
void operator += (lint &x,lint y)
{
    if (x.size()<y.size()) swap(x,y);
    for (int i=0;i<y.size();i++) x[i]+=y[i];
    for (int i=0;i<(int)x.size()-1;i++) x[i+1]+=x[i]/10,x[i]%=10;
    if (!x.empty() && x.back()>=10) x.push_back(x.back()/10),x[(int)x.size()-2]%=10;
}
inline void OUT(lint x)
{
    if (x.empty()) printf("0");
    else for (int i=(int)x.size()-1;i>=0;i--) printf("%d",x[i]);
}
inline void Main()
{
    scanf("%d%d%s",&n,&m,str),s=str,m++; lint res(0);
    for (int i=0;i<(1<<m);i++)
    {
        if (__builtin_popcount(i)!=n%m) continue;
        lint r(0); int bk=0;
        for (int j=0;j<m;j++)
        {
            int ln=((i&(1<<j)) ? n/m+1 : n/m); lint t(0);
            //cerr <<ln<<" $$\n";
            for (int k=bk;k<bk+ln;k++) t.push_back(s[k]-'0');
            reverse(t.begin(),t.end()); r+=t; bk+=ln;
        }
        if (r>res) res=r;
    }
    OUT(res),puts("");
}
int main()
{
    scanf("%d",&tac);
    while (tac--) Main();
    return 0;
}

詳細信息

Test #1:

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

input:

2
8 1
45455151
2 1
42

output:

9696
6

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 14ms
memory: 4240kb

input:

10
1301 6
56328399613959594774559774218276494124991536454496431869449134772679831477279356599352619469813771742358572734317965823527349354276551857226632977613336815474383422853946661428822284645652423563864641261338984158269966469425994769486371736593879954275146732544891889693921182364554588732946...

output:

3643487212740800349472686888551814148464560382557782154258648991735463075773466771863277332588565693103301914818440969321433505767069295563754530614887267182613398545970152359449210708177
2649942334464937947227447463303025498371336102030594072667220062367115685025653911100225182500251150989505913132...

result:

wrong answer 1st lines differ - expected: '286183755510664079479706773787...6909797866802717925250679901255', found: '364348721274080034947268688855...2613398545970152359449210708177'