常用代码模板
wwwidk1234 · · 个人记录
字符串分割
inline vector<string> split(string s,char c)
{
vector<string> res;
string t;
for(char _:s)
{
if(_==c)
{
res.push_back(t);
t.clear();
}
else t.push_back(_);
}
res.push_back(t);
return res;
}
string 转 int
int to_num(string s)
{
stringstream ss;int a;
ss<<s;ss>>a;
return a;
}
GCD(注意特判 0)
inline int gcd(int a,int b)
{
while(b^=a^=b^=a%=b);
return a;
}