結果
| 問題 |
No.1185 完全な3の倍数
|
| コンテスト | |
| ユーザー |
mmn15277198
|
| 提出日時 | 2021-07-11 16:47:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 133 ms / 2,000 ms |
| コード長 | 808 bytes |
| コンパイル時間 | 1,044 ms |
| コンパイル使用メモリ | 104,220 KB |
| 実行使用メモリ | 23,936 KB |
| 最終ジャッジ日時 | 2024-07-02 03:07:41 |
| 合計ジャッジ時間 | 4,285 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
#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;
long long n;
int d;
void dfs(string s) {
if (s.size() > d) {
return;
}
long long now = 0;
for (int i = 0; i < s.size(); i++) {
now *= 10LL;
now += s[i] - '0';
}
if (now > 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(99LL , n); i += 3) {
mp[to_string(i)]++;
}
dfs("3");
dfs("6");
dfs("9");
cout << mp.size() - 3 << endl;
return 0;
}
mmn15277198