結果
問題 |
No.1185 完全な3の倍数
|
ユーザー |
|
提出日時 | 2020-08-22 17:26:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 728 bytes |
コンパイル時間 | 1,552 ms |
コンパイル使用メモリ | 168,992 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-15 11:17:44 |
合計ジャッジ時間 | 2,807 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 11 WA * 28 |
コンパイルメッセージ
main.cpp: In function 'int p(std::string, int, int)': main.cpp:12:1: warning: control reaches end of non-void function [-Wreturn-type] 12 | } | ^
ソースコード
#include <bits/stdc++.h> using namespace std; int p(string S,int i,int count){ if(S.size()==i)return 0; if(S.at(i)=='0'){count/=4;return p(S,i+1,count);} if(S.at(i)=='3'){count/=4;return p(S,i+1,count)+count;} if(S.at(i)=='6'){count/=4;return p(S,i+1,count)+count*2;} if(S.at(i)=='9'){count/=4;return p(S,i+1,count)+count*3;} if(S.at(i)<'3')return count/4; if(S.at(i)<'6')return count/4*2; if(S.at(i)<'9')return count/4*3; } int main(){ int N;cin>>N; if(N<100){ cout<<(N-9)/3<<endl; return 0; } int ans=30; string S=to_string(N); int count=48; for(int i=3;i<S.size();i++){ ans+=count; count*=4; } cout<<p(S,0,count)+ans<<endl; }