QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#856230#9738. Make It Divisible22016020736#Compile Error//C++141.3kb2025-01-13 19:29:462025-01-13 19:29:46

Judging History

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

  • [2025-01-13 19:29:46]
  • 评测
  • [2025-01-13 19:29:46]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;

///int top;
int arr[20000009];


signed main() {
   int tt=0;
   scanf("%lld",&tt);
   while(tt--)
   {
       int top=0;
       set<int>st;
      int n,k;
      scanf("%lld%lld",&n,&k);
      for(int i=1;i<=n;i++)
      {
         int x;
         scanf("%lld",&x);
         st.insert(x);
      }
      if(st.size()==1)
      {
          int ans=k,sum=k*(k+1)/2;
          printf("%lld %lld\n",ans,sum);
          continue;
      }
      for(auto x:st)
      {
         arr[++top]=x;
      }
       int mx=arr[top],nx=arr[top-1];
       if(nx*2>=mx)
       {
            printf("0 0\n");
           continue;
       }
       else
       {
          int shu=mx-nx;
          set<int>xulie;
          for(int i=1;i*i<=shu;i++)
          {
              if(shu%i==0)
              {
                 xulie.insert(i+1);
                 xulie.insert(shu/i+1);
              }
          }
          xulie.insert(1);
          int ans=0,sum=0;
          for(auto x:xulie)
          {
              bool f=true;
             for(int j=1;j<top;j++)
             {
                if( (arr[top]+x)%(arr[j]+x)!=0) f=false;
             }
              if(f) sum+=x,ans=++;
          }
          printf("%lld %lld\n",ans,sum);
       }
   }
   return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:61:34: error: expected primary-expression before ‘;’ token
   61 |               if(f) sum+=x,ans=++;
      |                                  ^
answer.code:11:9: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |    scanf("%lld",&tt);
      |    ~~~~~^~~~~~~~~~~~
answer.code:17:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |       scanf("%lld%lld",&n,&k);
      |       ~~~~~^~~~~~~~~~~~~~~~~~
answer.code:21:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |          scanf("%lld",&x);
      |          ~~~~~^~~~~~~~~~~