結果
問題 |
No.639 An Ordinary Sequence
|
ユーザー |
![]() |
提出日時 | 2018-09-20 09:48:54 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 17 ms / 1,000 ms |
コード長 | 654 bytes |
コンパイル時間 | 736 ms |
コンパイル使用メモリ | 84,704 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2025-01-02 02:32:46 |
合計ジャッジ時間 | 1,648 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 |
ソースコード
#include <cstdio> #include <cstring> #include <string> #include <iostream> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> using namespace std; typedef long long int ll; typedef pair<int, int> P; ll a[1000000]; ll solve1(ll n){ if(a[n]>0) return a[n]; return a[n]=solve1(n/3)+solve1(n/5); } ll solve(ll n){ if(n<1000000) return a[n]; return solve(n/3)+solve(n/5); } int main() { ll n; cin>>n; a[0]=1; if(n<1000000){ cout<<solve1(n)<<endl; return 0; } for(ll i=1; i<1000000; i++){ solve1(i); } cout<<solve(n)<<endl; return 0; }