编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#22535 #2026. youngmagician笑传之谁是奶龙 Compile Error 0 0 ms 0 K C++ / 557 B 192024215032 2024-12-15 14:21:54
显示原始代码
#include <algorithm>
#include <queue>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
int main() {
    long long n;
    long long sum = 0;
    cin >> n;
    if (n >= 10) {
        while (n >= 10) {
            sum = 0;
            string str;
            str = to_string(n);
            for (int i = 0; i <= str.length() - 1; i++) {
                sum += (long long)str[i] - 48;
            }
            n = sum;
        }
        if (sum == 7) {
            cout << "YES";
        } else {
            cout << "NO";
        }
    } else {
        if (n == 7) {
            cout << "YES";
        } else {
            cout << "NO";
        }
    }
    return 0;
}

编译信息

/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:15:10: error: 'to_string' was not declared in this scope
   15 |    str = to_string(n);
      |          ^~~~~~~~~