結果
問題 | No.1185 完全な3の倍数 |
ユーザー |
|
提出日時 | 2020-08-22 14:18:57 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 794 bytes |
コンパイル時間 | 5,967 ms |
コンパイル使用メモリ | 129,640 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-24 09:28:01 |
合計ジャッジ時間 | 2,197 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 |
ソースコード
#include <iostream> #include <iomanip> #include <algorithm> #include <array> #include <cassert> #include <utility> #include <vector> long long int to(int d){ long long int res = 0; for(long long int mv = 3; d > 0; mv *= 10, d /= 4) res += (d % 4) * mv; return res; } int main(void){ std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(16); int n; std::cin >> n; int ok = 0, ng = (1 << 20) + 1; while(ng - ok > 1){ const int mid = (ng + ok) >> 1; const long long int v = to(mid); if(v <= n) ok = mid; else ng = mid; } int res = ok - 3; for(int x = 12; x <= 100 and x <= n; x += 3){ if( (x % 10) % 3 != 0 ) ++res; } std::cout << res << '\n'; return 0; }