結果
| 問題 |
No.1106 🦉 何事もバランスが大事
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-27 18:15:29 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 1,643 bytes |
| コンパイル時間 | 3,143 ms |
| コンパイル使用メモリ | 192,996 KB |
| 最終ジャッジ日時 | 2025-01-14 23:00:11 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 77 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:70:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
70 | scanf("%lld", &n);
| ~~~~~^~~~~~~~~~~~
ソースコード
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}
#define BASE 3725290298461914062LL
#define __BASE 201023764667814403LL
#define SIZE 27
#define __SIZE 108
//head
ll n;
ll dp[__SIZE+1], dpp[__SIZE+1];
ll *now = dp, *pre = dpp;
int cnt;
void add(int u) {
rep(i, __SIZE-u+1) {
now[i+u] += pre[i];
}
}
ll Q(vi z) {
memset(pre, 0, sizeof(dp));
cnt = 0;
for(int i = SIZE-1; i >= 0; i--) {
memset(now, 0, sizeof(dp));
rep(j, z[i]) {
now[cnt+j]++;
}
cnt += z[i];
rep(j, 5) add(j);
swap(now, pre);
}
pre[cnt]++;
return pre[SIZE<<1];
}
vi Z(ll z) {
vi res(SIZE);
rep(i, SIZE) {
res[i] = z%5;
z /= 5;
}
return res;
}
int main() {
scanf("%lld", &n);
printf("%lld\n", Q(Z(n+BASE)) - __BASE);
}