結果

問題 No.188 HAPPY DAY
ユーザー Eclair1015Eclair1015
提出日時 2018-07-08 14:19:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 636 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 61,504 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 10:02:06
合計ジャッジ時間 812 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>

int func(int n);
using namespace std;
int main() {
	int sum;
	int count = 0;

	for (int i = 1; i < 13; i++) {
		for (int j = 1; j < 32; j++) {

			if (i == 2 && j == 29) {
				break;
			}
			else if ((i == 4 || i == 6 || i == 9 || i == 11)) {
				if (j == 31) {
					break;
				}
			}

			if (j > 9) sum = func(j);
			else sum = j;
			//cout << sum << "\n";
			if (sum == i) {
				count++;
			}
		}
	}
	cout << count << endl;
	return 0;
}

int func(int n) {
	int sum=0;
	if (n < 10) {
		return n;
	} else{
		while (n > 0) {
			sum += n % 10;
			n /= 10;
		}
		return sum;
	}
}
0