結果

問題 No.188 HAPPY DAY
ユーザー tetsuzuki1115tetsuzuki1115
提出日時 2017-09-26 21:33:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 819 bytes
コンパイル時間 599 ms
コンパイル使用メモリ 74,356 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-08-30 01:28:32
合計ジャッジ時間 932 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int happy = 0;
    int x[4] = { 4,6,9,11 };
    
    for ( int m = 1; m <= 12; m++ ) {
        
        int D = m == 2 ? 28 : m == 4 || m == 6 || m == 9 || m == 11 ? 30 : 31;
        for ( int d = 1; d <= D; d++ ) {
            
            int x = 0;
            for ( int i = 0; i < to_string(d).length(); i++ ) {
                x += to_string(d)[i] - '0';
            }
            
            if ( x == m ) { happy++; }
            
        }
    }
    
    cout << happy << endl;
    
    return 0;
}
0