結果

問題 No.220 世界のなんとか2
ユーザー syoken_desukasyoken_desuka
提出日時 2015-07-24 01:33:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,939 bytes
コンパイル時間 905 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 21:57:36
合計ジャッジ時間 1,635 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:80:8: warning: extra tokens at end of #endif directive [-Wendif-labels]
 #endif _DEBUG
        ^~~~~~

ソースコード

diff #

#include <algorithm>
#include <array>
#include <sstream>
#include <cstdio>
#include <functional>
#include <cstdlib>
#include <cctype>
#include <ostream>
#include<complex>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <string>

using namespace std;
#define OB (bitset<32>)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define ALLOF(c) begin(), (c),end()

typedef long long ll;

#define PI acos(-1)
#define EPS 1e-11
#define MOD 1000000007

int main()
{
    int n ;
    cin >> n;

    ll dp3[20];
    ll dp3andmod3[20][10];
    fill(dp3,dp3+20,0);
    fill(*dp3andmod3,*dp3andmod3+20*10,0);

    ll e10 = 1;
    dp3[0] = 0;
    dp3andmod3[0][3] =1;
    for (int i = 1; i < n+1; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            if (j == 3)
            {
                dp3[i] += e10 ;
            }
            else
            {
                dp3[i] += dp3[i-1];
            }

        }
        for (int j = 0; j < 10; j++)
        {
            for (int k = 0; k < 10; k++)
            {
                if ((k+j)% 3 == 0)
                {
                    if (j == 3)
                    {
                        dp3andmod3[i][j] += e10;
                    }
                    else
                    {

#ifdef _DEBUG
                        cout <<"j  " << j << endl; 
                        cout <<" val = " << k << endl;
#endif _DEBUG      

                        dp3andmod3[i][j] += dp3andmod3[i-1][k];
                    }
                    
                }
            }
        }
        e10 *= 10;
    }
    int sum = 0;
    for (int k = 0; k < 10; k++)
    {
        sum += dp3andmod3[n-1][k];
    }

    cout <<dp3[n] +e10 /3 - sum   << endl;
    return 0;
}



0