結果
| 問題 |
No.1185 完全な3の倍数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-22 13:46:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 624 bytes |
| コンパイル時間 | 739 ms |
| コンパイル使用メモリ | 72,184 KB |
| 最終ジャッジ日時 | 2025-01-13 08:03:53 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
constexpr int D = 9;
void solve() {
int n;
std::cin >> n;
int ans = 0;
for (int b = 0; b < (1 << D * 2); ++b) {
int c = b, x = 0;
for (int i = 0; i < D; ++i) {
x = x * 10 + (c % 4 * 3);
c /= 4;
}
if (10 <= x && x <= n) ++ans;
}
for (int x = 12; x <= 99; x += 3) {
if ((x % 10) % 3 == 0) continue;
if (x <= n) ++ans;
}
std::cout << ans << "\n";
}
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
solve();
return 0;
}