QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#114720#5050. Valuehos_lyricWA 1ms3732kbC++142.3kb2023-06-23 10:25:132023-06-23 10:25:16

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-23 10:25:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3732kb
  • [2023-06-23 10:25:13]
  • 提交

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 <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; }


int N;
vector<Int> A, B;

int main() {
  for (; ~scanf("%d", &N); ) {
    A.resize(N + 1); for (int i = 1; i <= N; ++i) scanf("%lld", &A[i]);
    B.resize(N + 1); for (int i = 1; i <= N; ++i) scanf("%lld", &B[i]);
    
    Int ans = A[1];
    vector<int> vis(N + 1, 0);
    for (int i = 2; i <= N; ++i) if (!vis[i]) {
      vector<int> is{1, i};
      for (int j = i; j <= N / i; ) {
        j *= i;
        is.push_back(j);
      }
      const int isLen = is.size();
// cerr<<"is = "<<is<<endl;
      for (const int j : is) {
        vis[j] = 1;
      }
      Int mx = 0;
      for (int p = 0; p < 1 << isLen; p += 2) {
        int bad = 0;
        for (int k = 1; k < isLen; ++k) if (p >> k & 1) {
          for (int l = 2 * k; l < isLen; l += k) {
            bad |= 1 << l;
          }
        }
        Int score = 0;
        for (int k = 1; k < isLen; ++k) if (p >> k & 1) {
          score += A[is[k]];
          if (bad >> k & 1) {
            score -= B[is[k]];
          }
        }
        chmax(mx, score);
      }
      ans += mx;
    }
    printf("%lld\n", ans);
  }
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3676kb

input:

4
1 1 1 2
1 1 1 1

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3716kb

input:

4
1 1 1 1
1 1 1 2

output:

3

result:

ok 1 number(s): "3"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

1
4
10

output:

4

result:

ok 1 number(s): "4"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3664kb

input:

2
6 8
2 4

output:

14

result:

ok 1 number(s): "14"

Test #5:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

5
1 6 10 5 1
7 1 5 10 9

output:

18

result:

ok 1 number(s): "18"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

10
2 2 8 10 2 10 8 10 6 5
9 2 7 4 2 2 8 3 10 10

output:

55

result:

ok 1 number(s): "55"

Test #7:

score: 0
Accepted
time: 1ms
memory: 3724kb

input:

10
8 2 28 71 6 85 90 19 75 99
58 32 12 97 22 54 95 2 22 41

output:

459

result:

ok 1 number(s): "459"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

10
499378161 580312139 297991977 488549686 446728905 94747359 449577305 348551824 91900269 509840562
195391767 900284766 199070364 13166132 91649641 462416747 349376583 358291497 486025165 865291797

output:

3353959962

result:

ok 1 number(s): "3353959962"

Test #9:

score: 0
Accepted
time: 1ms
memory: 3732kb

input:

100
457992034 292706810 675334392 753902137 68910383 43232856 93369738 421897111 2553628 571090809 308473918 823046294 353799547 596697775 689497551 634976771 180311057 487479264 238310828 773159036 689460373 21840389 460321400 444499701 961273652 170165163 343911050 28242743 466702096 877051765 309...

output:

42242895657

result:

ok 1 number(s): "42242895657"

Test #10:

score: 0
Accepted
time: 1ms
memory: 3664kb

input:

100
486342294 640034805 116328197 318162835 39561592 805725108 594609889 653511108 294477518 652922309 577371886 601529202 961360083 316914599 630048249 821394943 617577478 471190718 842113363 185539825 830514090 434572500 858130769 573409395 372400199 154412691 349010381 448381393 329822759 7017456...

output:

49995353551

result:

ok 1 number(s): "49995353551"

Test #11:

score: -100
Wrong Answer
time: 1ms
memory: 3692kb

input:

1000
448894631 183123026 397536202 695859698 441207641 802550098 754562453 970029739 793685893 84998873 617823553 939902778 48522348 210952668 110891265 472327126 769948243 504528886 484642894 899868060 873491202 936738789 691583586 408761099 273650760 832514570 933444283 906602631 957885556 2390632...

output:

481292041590

result:

wrong answer 1st numbers differ - expected: '481253884637', found: '481292041590'