結果

問題 No.1185 完全な3の倍数
ユーザー akaneakane
提出日時 2020-08-22 15:03:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,049 bytes
コンパイル時間 2,047 ms
コンパイル使用メモリ 196,100 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 09:26:20
合計ジャッジ時間 3,475 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (n); i++)
using namespace std;
using ll = long long;

int ctoi(char x){
    return x - '0';
}

int main(){
    ios::sync_with_stdio(false);
    int N; cin>>N;
    if(N<10){
        cout << 0 << endl; return 0;
    }

    ll ans = 0;
    ll t=10;
    // 2桁の特殊処理
    while(t<100){
        int a = t%10;
        int b = (t/10)%t;
        if((a+b)%3==0 && a%3!=0 && b%3!=0){
            ans ++;
        }
        if(t==N) break;
        t++;
    }
    cerr << ans << endl;

    // n桁以上の処理
    string s = to_string(N);
    cerr << s.size() << endl;
    int sum=1;
    for(int i=0; i<s.size(); i++){
        int z = 0;
        if(i!=0) z++;
        sum *= ctoi(s[i])/3 + z;
    }
    cerr << sum << endl;

    // n桁未満の処理
    int sum2=1;
    for(int i=0; i<s.size(); i++){
        if(i==0){
            sum2 *= (ctoi(s[i]) + 2)/3;
        }else{
            sum2 *= 4;
        }
    }
    cerr << sum2 << endl;

    cout << ans + sum + sum2 - 4 << endl;


}
0