QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#496765#9133. Function with Many Maximumshos_lyricAC ✓34ms6904kbC++142.0kb2024-07-28 15:46:092024-07-28 15:46:10

Judging History

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

  • [2024-07-28 15:46:10]
  • 评测
  • 测评结果:AC
  • 用时:34ms
  • 内存:6904kb
  • [2024-07-28 15:46:09]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")

/*
  2
  1 3
  1 1 4
  1 1 1 5
  1 1 1 1 6
*/

constexpr Int M = 100'000;
constexpr Int N = 500'000;
constexpr Int L = 1'000'000'000'000LL;

int main() {
  vector<Int> A(N);
  for (Int i = 0; i <= N - 1 - M*2; ++i) {
    A[i] = L - i;
  }
  for (Int i = N - 1 - M*2; i < N - 1; i += 2) {
    // (i+1) A[i] = A[i+1] + (i+4) A[i+2]
    const Int tar = (i+1) * A[i];
    A[i+2] = (tar - 1) / (i+4 + 1);
    A[i+1] = tar - (i+4) * A[i+2];
// cerr<<i<<": "<<A[i]<<" "<<A[i+1]<<" "<<A[i+2]<<endl;
    assert(A[i] > A[i+1]);
    assert(A[i+1] > A[i+2]);
  }
cerr<<"A[N-1] = "<<A[N-1]<<endl;
  
  printf("%lld\n", N);
  for (Int i = 0; i < N; ++i) {
    if (i) printf(" ");
    printf("%lld", A[i]);
  }
  puts("");
  return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 34ms
memory: 6904kb

input:

4

output:

500000
1000000000000 999999999999 999999999998 999999999997 999999999996 999999999995 999999999994 999999999993 999999999992 999999999991 999999999990 999999999989 999999999988 999999999987 999999999986 999999999985 999999999984 999999999983 999999999982 999999999981 999999999980 999999999979 999999...

result:

ok n=500000, max_a=1000000000000, max_num=100001 >= 4

Test #2:

score: 0
Accepted
time: 30ms
memory: 6740kb

input:

100000

output:

500000
1000000000000 999999999999 999999999998 999999999997 999999999996 999999999995 999999999994 999999999993 999999999992 999999999991 999999999990 999999999989 999999999988 999999999987 999999999986 999999999985 999999999984 999999999983 999999999982 999999999981 999999999980 999999999979 999999...

result:

ok n=500000, max_a=1000000000000, max_num=100001 >= 100000

Extra Test:

score: 0
Extra Test Passed