Submission #615992


Source Code Expand

// scanf 等でエラーを出さないように追加
#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>

using namespace std;


int main() {

	int N;
	scanf("%d", N);


	int num = 0;

	for (int i = 5; i <= N; i += 10) {
		int digit = strlen(to_string(i).c_str);
		int dec_digit = (int)pow(10, digit-1);

		if (i / dec_digit == 2) {
			num++;
		}
	}

	printf("%d\n", num);


	return 0;
}

Submission Info

Submission Time
Task A - ニコニコ数
User Umineko4396
Language C++ (GCC 4.9.2)
Score 0
Code Size 579 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:21:15: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘int’ [-Wformat=]
  scanf("%d", N);
               ^
./Main.cpp:27:33: error: ‘to_string’ was not declared in this scope
   int digit = strlen(to_string(i).c_str);
                                 ^
./Main.cpp:21:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", N);
                ^