結果
| 問題 | 
                            No.1185 完全な3の倍数
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ate
                         | 
                    
| 提出日時 | 2020-08-22 13:53:38 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 5 ms / 2,000 ms | 
| コード長 | 446 bytes | 
| コンパイル時間 | 2,859 ms | 
| コンパイル使用メモリ | 193,656 KB | 
| 最終ジャッジ日時 | 2025-01-13 08:09:16 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 39 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
#define rep(i,n) for(int i=0;i<(n);++i)
signed main(){
  ll n;
  cin>>n;
  ll ans = 0;
  auto dfs =[&](auto&&dfs,ll x)->void{
    if(100<=x and x<=n)ans++;
    if(x>n)return;
    if(x!=0)dfs(dfs,x*10);
    dfs(dfs,x*10+3);
    dfs(dfs,x*10+6);
    dfs(dfs,x*10+9);
  };
  dfs(dfs,0);
  for(int i=10;i<=min<ll>(n,100);++i){
    if(i%3==0)ans++;
  }
  cout<<(ans)<<endl;
}
            
            
            
        
            
ate