結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 2 ms
5,376 KB
testcase_40 WA -
testcase_41 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 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)+count;}
    if(S.at(i)=='6'){count/=(i==0? 3:4);return p(S,i+1,count)+count*2;}
    if(S.at(i)=='9'){count/=(i==0? 3:4);return p(S,i+1,count)+count*3;}
    if(S.at(i)<'3')return count/(i==0? 3:4);
    if(S.at(i)<'6')return count/(i==0? 3:4)*2;
    if(S.at(i)<'9')return count/(i==0? 3: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;
}
0