結果
問題 |
No.1185 完全な3の倍数
|
ユーザー |
|
提出日時 | 2021-06-10 07:32:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 698 bytes |
コンパイル時間 | 1,521 ms |
コンパイル使用メモリ | 170,648 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-29 11:49:47 |
合計ジャッジ時間 | 2,817 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 15 WA * 24 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int lim = min(100,n); vector<int> d; int count =0; bool last=true; while(n>0){ d.push_back(n%10); n /= 10; last &= d.back()%3==0; } //for(auto& i : d) cout << i << ' ' ; cout << endl; bool dig = false; for(auto it = d.rbegin(); it != d.rend(); ++it){ count *=4; if(!dig)count += (*it)/3; else count +=3; if(dig && (*it)==0) dig = true; else if((*it)%3!=0) dig = true; else dig = false; } count -= 3; //cout << count << endl; for(int i=10; i<=lim; i++) if(i%3==0 && i%10%3 !=0) count ++; if(last) count ++; cout << count << endl; }