1 Star 0 Fork 0

ydsungan/algorithm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test_20_last_three_digits.cpp 961 Bytes
一键复制 编辑 原始数据 按行查看 历史
ydsungan 提交于 2021-10-07 20:09 +08:00 . 1007
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <math.h>
#include <malloc.h>
int main()
{
using namespace std;
string input ;
getline(cin, input);
int m, n;
vector<char> input_(input.size());
input_.assign(input.begin(), input.end());
string m_ = "";
string n_ = "";
int flag = 0;
for (unsigned int i = 0; i < input_.size(); i++){
if (input_[i] != ' '){
if (flag == 0)
m_ += input_[i];
else
n_ += input_[i];
} else {
flag = 1;
}
}
m = stoi(m_);
n = stoi(n_);
int res = pow(m, n);
string res_ = to_string(res);
const char *res2 = res_.data();
char *res2_ = (char*)malloc(4);
res2_[0] = res2[res_.size() - 3];
res2_[1] = res2[res_.size() - 2];
res2_[2] = res2[res_.size() - 1];
res2_[3] = '\0';
cout << res2_ << endl;
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ydsungan/algorithm.git
git@gitee.com:ydsungan/algorithm.git
ydsungan
algorithm
algorithm
master

搜索帮助