結果
| 問題 |
No.639 An Ordinary Sequence
|
| コンテスト | |
| ユーザー |
ama_nuko
|
| 提出日時 | 2018-11-27 03:38:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 1,000 ms |
| コード長 | 925 bytes |
| コンパイル時間 | 903 ms |
| コンパイル使用メモリ | 97,416 KB |
| 実行使用メモリ | 18,824 KB |
| 最終ジャッジ日時 | 2025-01-02 02:42:02 |
| 合計ジャッジ時間 | 2,037 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 |
ソースコード
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
using namespace std;
typedef pair<int, int> P;
const int INF = 1e15;
const int MOD = 1e9+7;
vector<int> dp(1e6);
int f(int x){
if(x < 1e6){
return dp[x];
}
return f(x / 3) + f(x / 5);
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
dp = vector<int>(1e6);
dp[0] = 1;
for(int i = 1; i < 1e6; i++){
dp[i] = dp[i/3] + dp[i/5];
}
cout << f(n) << endl;
return 0;
}
ama_nuko