結果
| 問題 | No.1185 完全な3の倍数 |
| コンテスト | |
| ユーザー |
akane
|
| 提出日時 | 2020-08-22 15:14:06 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 751 bytes |
| 記録 | |
| コンパイル時間 | 1,239 ms |
| コンパイル使用メモリ | 211,544 KB |
| 実行使用メモリ | 9,728 KB |
| 最終ジャッジ日時 | 2026-06-12 17:30:22 |
| 合計ジャッジ時間 | 8,177 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 38 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (n); i++)
using namespace std;
using ll = long long;
int ctoi(char x){
return x - '0';
}
int main(){
ios::sync_with_stdio(false);
int N; cin>>N;
ll ans = 0;
ll t=10;
// 2桁の特殊処理
while(t<100){
int a = t%10;
int b = (t/10)%t;
if((a+b)%3==0){
ans ++;
}
if(t==N) break;
t++;
}
if(N<100){
cout << ans << endl; return 0;
}
for(int i=111; i<=N; i+=3){
string s = to_string(i);
bool flg=true;
for(int j=0; j<s.size(); j++){
if(ctoi(s[j])%3 != 0) flg=false;
}
if(flg) ans++;
}
cout << ans << endl;
}
akane