QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#621419#7789. Outro: True Love WaitsZhou_JKCompile Error//C++233.1kb2024-10-08 14:23:142024-10-08 14:23:26

Judging History

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

  • [2024-10-08 14:23:26]
  • 评测
  • [2024-10-08 14:23:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int N=1000005;
constexpr int MOD=1000000007;
int qpow(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1) res=(long long)res*a%MOD;
        a=(long long)a*a%MOD,b>>=1;
    }
    return res;
}
int getinv(int x)
{
    return qpow(x,MOD-2);
}
string a,b;
int k;
void solve()
{
    cin>>a>>b>>k;
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    string s=a;
    while(s.size()<b.size()) s+='0';
    for(int i=0;i<(int)s.size();i++)
        if(i<(int)b.size()&&b[i]=='1') s[i]=s[i]=='0'?'1':'0';
    while((int)s.size()>1&&s.back()=='0') s.pop_back();
    if(s=="0")
    {
        int ans=(long long)(qpow(4,k)-4+MOD)*getinv(3)%MOD;
        cout<<ans<<"\n";
        return;
    }
    int cnt=0;
    for(int i=0;i+1<(int)s.size();i+=2)
        if(s[i]=='0'&&s[i+1]=='0') cnt++;
    if(cnt<k-1)
    {
        cout<<-1<<"\n";
        return;
    }
    if(s.size()%2==1) s+='0';
    int pw=1;
    int ans=0;
    for(int i=0;i+1<(int)s.size();i+=2)
    {
        int c=0;
        if(s[i]=='1'&&s[i+1]=='0') c=1;#include<bits/stdc++.h>
using namespace std;
constexpr int N=1000005;
constexpr int MOD=1000000007;
int qpow(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1) res=(long long)res*a%MOD;
        a=(long long)a*a%MOD,b>>=1;
    }
    return res;
}
int getinv(int x)
{
    return qpow(x,MOD-2);
}
string a,b;
int k;
void solve()
{
    cin>>a>>b>>k;
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    string s=a;
    while(s.size()<b.size()) s+='0';
    for(int i=0;i<(int)s.size();i++)
        if(i<(int)b.size()&&b[i]=='1') s[i]=s[i]=='0'?'1':'0';
    while((int)s.size()>1&&s.back()=='0') s.pop_back();
    if(s=="0")
    {
        int ans=(long long)(qpow(4,k)-4+MOD)*getinv(3)%MOD;
        cout<<ans<<"\n";
        return;
    }
    int cnt=0;
    for(int i=0;i+1<(int)s.size();i+=2)
        if(s[i]=='0'&&s[i+1]=='0') cnt++;
    if(cnt<k-1)
    {
        cout<<-1<<"\n";
        return;
    }
    if(s.size()%2==1) s+='0';
    int pw=1;
    int ans=0;
    for(int i=0;i+1<(int)s.size();i+=2)
    {
        int c=0;
        if(s[i]=='1'&&s[i+1]=='0') c=1;
        else if(s[i]=='1'&&s[i+1]=='1') c=2;
        else if(s[i]=='0'&&s[i+1]=='1') c=3;
        int val=(long long)(qpow(4,i/2+1)-1+MOD)*getinv(3)%MOD;
        ans=(ans+(long long)c*val)%MOD;
    }
    ans=(ans+(long long)(qpow(4,k)-4+MOD)*getinv(3))%MOD;
    cout<<ans<<"\n";
    return; 
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int T;
    cin>>T;
    while(T--)
        solve(); 
    return 0;
}
        else if(s[i]=='1'&&s[i+1]=='1') c=2;
        else if(s[i]=='0'&&s[i+1]=='1') c=3;
        int val=(long long)(qpow(4,i/2+1)-1+MOD)*getinv(3)%MOD;
        ans=(ans+(long long)c*val)%MOD;
    }
    ans=(ans+(long long)(qpow(4,k)-4+MOD)*getinv(3))%MOD;
    cout<<ans<<"\n";
    return; 
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int T;
    cin>>T;
    while(T--)
        solve(); 
    return 0;
}

Details

answer.code:51:40: error: stray ‘#’ in program
   51 |         if(s[i]=='1'&&s[i+1]=='0') c=1;#include<bits/stdc++.h>
      |                                        ^
answer.code: In function ‘void solve()’:
answer.code:51:49: error: ‘bits’ was not declared in this scope
   51 |         if(s[i]=='1'&&s[i+1]=='0') c=1;#include<bits/stdc++.h>
      |                                                 ^~~~
answer.code:51:54: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
   51 |         if(s[i]=='1'&&s[i+1]=='0') c=1;#include<bits/stdc++.h>
      |                                                      ^~~~
      |                                                      std
answer.code:51:41: error: ‘include’ was not declared in this scope
   51 |         if(s[i]=='1'&&s[i+1]=='0') c=1;#include<bits/stdc++.h>
      |                                         ^~~~~~~
answer.code:52:1: error: expected primary-expression before ‘using’
   52 | using namespace std;
      | ^~~~~
answer.code:56:1: error: a function-definition is not allowed here before ‘{’ token
   56 | {
      | ^
answer.code:66:1: error: a function-definition is not allowed here before ‘{’ token
   66 | {
      | ^
answer.code:72:1: error: a function-definition is not allowed here before ‘{’ token
   72 | {
      | ^
answer.code:111:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  111 | int main()
      |         ^~
answer.code:111:9: note: remove parentheses to default-initialize a variable
  111 | int main()
      |         ^~
      |         --
answer.code:111:9: note: or replace parentheses with braces to value-initialize a variable
answer.code:112:1: error: a function-definition is not allowed here before ‘{’ token
  112 | {
      | ^
answer.code:121:9: error: ‘else’ without a previous ‘if’
  121 |         else if(s[i]=='1'&&s[i+1]=='1') c=2;
      |         ^~~~