結果

問題 No.1185 完全な3の倍数
コンテスト
ユーザー mmn15277198
提出日時 2020-08-23 20:54:59
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 549 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 500 ms
コンパイル使用メモリ 106,072 KB
実行使用メモリ 10,024 KB
最終ジャッジ日時 2026-09-18 21:59:10
合計ジャッジ時間 80,726 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 TLE * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

bool func(long long x){
	string s=to_string(x);
	for(int i=0;i<s.size()-1;i++){
		for(int j=i+1;j<s.size();j++){
			int a1=s[i]-'0';
			int a2=s[j]-'0';
			if((a1+a2)%3==0)continue;
			return false;
		}
	}
	return true;
}

int main(){
	long long n;
	cin >> n;
	long long cnt=0;
	for(long long i=12;i<=n;i+=3){
		if(func(i))cnt++;
	}
	cout << cnt << endl;
	return 0;
}
0