結果
| 問題 | 
                            No.1185 完全な3の倍数
                             | 
                    
| コンテスト | |
| ユーザー | 
                             chocorusk
                         | 
                    
| 提出日時 | 2020-08-22 13:12:26 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 6 ms / 2,000 ms | 
| コード長 | 869 bytes | 
| コンパイル時間 | 2,766 ms | 
| コンパイル使用メモリ | 120,828 KB | 
| 最終ジャッジ日時 | 2025-01-13 07:17:49 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 39 | 
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll n;
int ans;
void dfs(int k, ll x){
	if(k>9) return;
	if(k>=3){
		if(x<=n) ans++;
	}
	for(int i=0; i<10; i+=3){
		ll x1=x*10+i;
		dfs(k+1, x1);
	}
}
int main()
{
	cin>>n;
	for(int i=12; i<100; i+=3){
		if(i<=n) ans++;
	}
	dfs(1, 3);
	dfs(1, 6);
	dfs(1, 9);
	cout<<ans<<endl;
	return 0;
}
            
            
            
        
            
chocorusk