結果

問題 No.1185 完全な3の倍数
ユーザー cpcznksutbeoacpcznksutbeoa
提出日時 2020-08-22 17:23:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 720 bytes
コンパイル時間 2,806 ms
コンパイル使用メモリ 165,084 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 11:19:48
合計ジャッジ時間 2,752 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 WA -
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 WA -
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
6,940 KB
testcase_31 AC 1 ms
6,944 KB
testcase_32 AC 1 ms
6,944 KB
testcase_33 WA -
testcase_34 AC 1 ms
6,944 KB
testcase_35 AC 1 ms
6,944 KB
testcase_36 AC 1 ms
6,944 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 1 ms
6,940 KB
testcase_39 AC 1 ms
6,940 KB
testcase_40 WA -
testcase_41 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 | }
      | ^

ソースコード

diff #

#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 0;
    if(S.at(i)<'6')return count/3;
    if(S.at(i)<'9')return count/3*2;
}
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