結果
| 問題 | 
                            No.1185 完全な3の倍数
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-09-06 19:13:20 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 15 ms / 2,000 ms | 
| コード長 | 473 bytes | 
| コンパイル時間 | 1,991 ms | 
| コンパイル使用メモリ | 194,440 KB | 
| 最終ジャッジ日時 | 2025-01-14 07:58:36 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 39 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
int n;
vector<lint> res;
void dfs(lint x){
	if(x>n) return;
	if(x>=10) res.emplace_back(x);
	dfs(10*x);
	dfs(10*x+3);
	dfs(10*x+6);
	dfs(10*x+9);
}
int main(){
	scanf("%d",&n);
	dfs(3);
	dfs(6);
	dfs(9);
	rep(a,10) if(a>0) rep(b,10) if((a+b)%3==0 && a%3!=0 && b%3!=0) {
		if(10*a+b<=n) res.emplace_back(10*a+b);
	}
	printf("%ld\n",res.size());
	return 0;
}