Submission #616043
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> int main() { int N = 0; scanf("%d", N); int num = 0; for (int i = 5; i <= N; i += 10) { int digit = strlen(std::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 | 566 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:19:15: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘int’ [-Wformat=] scanf("%d", N); ^ ./Main.cpp:25:22: error: ‘to_string’ is not a member of ‘std’ int digit = strlen(std::to_string(i).c_str()); ^ ./Main.cpp:19:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", N); ^