結果
| 問題 |
No.1185 完全な3の倍数
|
| コンテスト | |
| ユーザー |
akane
|
| 提出日時 | 2020-08-22 15:14:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 751 bytes |
| コンパイル時間 | 2,261 ms |
| コンパイル使用メモリ | 192,088 KB |
| 最終ジャッジ日時 | 2025-01-13 09:21:35 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 TLE * 22 |
ソースコード
#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