先打表,否则TLE

My Code:

#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

const int N = 32767;

int c1[N+1], c2[N+1];

int main() {
//freopen("data.in", "r", stdin);

int n, i, j, k;

for(i = 0; i <= N; i++) {
c1[i] = 1; c2[i] = 0;
}
for(i = 2; i <= 3; i++) {
for(j = 0; j <= N; j++) {
for(k = 0; k + j <= N; k += i)
c2[k+j] += c1[j];
}
for(j = 0; j <= N; j++) {
c1[j] = c2[j]; c2[j] = 0;
}
}

while(~scanf("%d", &n)) {
cout << c1[n] << endl;
}
return 0;
}



相关文章:

  • 2022-12-23
  • 2021-07-13
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-25
猜你喜欢
  • 2021-11-20
  • 2022-12-23
  • 2021-11-30
  • 2021-06-06
  • 2022-12-23
相关资源
相似解决方案