結果

問題 No.1185 完全な3の倍数
ユーザー CaliforniumerCaliforniumer
提出日時 2020-08-22 17:47:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 836 bytes
コンパイル時間 1,983 ms
コンパイル使用メモリ 165,432 KB
実行使用メモリ 17,088 KB
最終ジャッジ日時 2024-04-23 11:37:26
合計ジャッジ時間 8,708 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N;cin>>N;
    vector<long long>F{3,30,300,3000,30000,300000,3000000,30000000,300000000};
    if(N<300)cout<<N/3-3<<endl;
    else{
        long long K=30;
        /*string S=to_string(N);int U=((S[0]-'0')-1)/3;
        for(int X=0;X<S.size()-1;X++){
            U*=4;
        }
        K+=U;
            S.erase(0,1);int F=stoi(S);*/
            for(long long X=300;X<=N;X+=3){
                string M=to_string(X);bool J=false;
                if((M[0]-'0')%3!=0)M+=F[M.size()-1];
                for(int Y=0;Y<M.size();Y++){
                    if(((int)(M[Y]-'0'))%3!=0){
                        J=true;break;
                    }
                }
                if(!J){
                  K++;
                }
            }
        cout<<K<<endl;
    }
}
0