QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#179822#5674. Sum of RemaindersYshanqianWA 0ms3656kbC++141.3kb2023-09-15 10:27:352023-09-15 10:27:35

Judging History

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

  • [2023-09-15 10:27:35]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3656kb
  • [2023-09-15 10:27:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define xx first
#define yy second
#define endl "\n"
#define lowbit(x) x & (-x)
#define int long long
#define ull unsigned long long
#define pb push_back
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define Ysanqian ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
const int N = 1e6 + 10, M = 1010, inf = 0x3f3f3f3f, mod = 18446, P = 13331;
const double eps = 1e-8;
int n;
int a[N];
bool flag;
vector<int> ans;
void solve()
{
  cin >> n;
  int num = a[1];
  int cnt = a[1];
  for (int i = 2; i <= n; i++)
  {
    int sum = 0;
    for (auto ed : ans)
      sum += i % ed;
    a[i] -= sum;
    if (a[i] == 0)
      ans.pb(i);
    if (a[i] < cnt * i)
    {
      int x = a[i] / i;
      int y = cnt;
      y -= x;
      cnt -= y;
      for (int j = 1; j <= y; j++)
      {
        ans.pb(i);
        if (ans.size() == a[1])
        {
          flag = 1;
          break;
        }
      }
      if (flag)
        break;
    }
  }
  cout << a[1] << ' ';
  for (auto ed : ans)
    cout
        << ed << ' ';
}
signed main()
{
  Ysanqian;
  int T;
  T = 1;
  // cin >> T;
  while (T--)
    solve();
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3656kb

input:

16
4 6 10 12 6 8 12 14 18 10
3 5 9 11 5 7

output:

0 2 4 8 16 

result:

wrong answer 1st lines differ - expected: '4 2 5 5 11', found: '0 2 4 8 16 '