結果
問題 |
No.1185 完全な3の倍数
|
ユーザー |
![]() |
提出日時 | 2021-07-11 16:40:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 699 bytes |
コンパイル時間 | 1,251 ms |
コンパイル使用メモリ | 105,472 KB |
実行使用メモリ | 22,656 KB |
最終ジャッジ日時 | 2024-07-02 03:07:17 |
合計ジャッジ時間 | 4,238 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 RE * 1 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <functional> #include <queue> #include <map> #include <cmath> #include <iomanip> using namespace std; const long long MOD = (long long)(1e9) + 7; map<string , int> mp; int n , d; void dfs(string s) { if (s.size() > d) { return; } if ((int)stoi(s) > n) { return; } mp[s]++; dfs(s + "3"); dfs(s + "6"); dfs(s + "9"); dfs(s + "0"); return; } int main() { //cout << fixed << setprecision(15); cin >> n; d = to_string(n).size(); for (int i = 12; i <= min(99 , n); i += 3) { mp[to_string(i)]++; } dfs("3"); dfs("6"); dfs("9"); cout << mp.size() - 3 << endl; return 0; }