0 Compile Error

foo.cc:2:14: error: expected '{' before ';' token
 namespace std;
              ^
foo.cc: In function 'int main()':
foo.cc:6:5: error: 'cin' was not declared in this scope
     cin>>n;
     ^~~
foo.cc:6:5: note: suggested alternative:
In file included from foo.cc:1:
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../include/c++/8.3.0/iostream:60:18: note:   'std::cin'
   extern istream cin;  /// Linked to standard input
                  ^~~
foo.cc:14:13: error: 'cout' was not declared in this scope
             cout<<i;
             ^~~~
foo.cc:14:13: note: suggested alternative:
In file included from foo.cc:1:
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../include/c++/8.3.0/iostream:61:18: note:   'std::cout'
   extern ostream cout;  /// Linked to standard output
                  ^~~~

代码

#include <iostream>
namespace std;
int main()
{
    int n,m,g,s;
    cin>>n;
    for(int i=10;i<=n;i++)
    {
        g=i%10;
        s=i-(i%10)/10;
        m=g+s;
        if(n%m==0)
        {
            cout<<i;
        }
    }
    return 0;
}

信息

递交者
题目
P431  自整除数
比赛
2024年3月等考一级题单
语言
C++ 98
递交时间
1 年前
评测时间
1 年前
分数
0
总耗时
0ms
峰值内存
0 Bytes