結果

問題 No.1185 完全な3の倍数
ユーザー cpcznksutbeoacpcznksutbeoa
提出日時 2020-08-22 17:36:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 838 bytes
コンパイル時間 1,646 ms
コンパイル使用メモリ 165,944 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-16 00:11:04
合計ジャッジ時間 3,143 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,384 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int p(std::string, int, int)’ 内:
main.cpp:12:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   12 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int p(string S,int i,int count){
    if(S.size()==i)return 1;
    if(S.at(i)=='0'){count/=4;return p(S,i+1,count);}
    if(S.at(i)=='3'){count/=(i==0? 3:4);return p(S,i+1,count)+(i==0? 0:count);}
    if(S.at(i)=='6'){count/=(i==0? 3:4);return p(S,i+1,count)+count*(i==0? 1:2);}
    if(S.at(i)=='9'){count/=(i==0? 3:4);return p(S,i+1,count)+count*(i==0? 2:3);}
    if(S.at(i)<'3')return (i==0? 0:count/4);
    if(S.at(i)<'6')return count/(i==0? 3:4)*(i==0? 1:2);
    if(S.at(i)<'9')return count/(i==0? 3:4)*(i==0? 2: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;
}
0