#include<bits/stdc++.h>
using namespace std;
int main()
{
long long x,n;
long long total=1;
cin>>x>>n;
for(int i=1;i<=n;i++)
{
total*=x;
}
int a=total%1000;
//total%1000=000
if(total<1000)
{
cout<<total;
}
else
{
if(a==0)
{
cout<<"000";
}
//total%1000=001
else if(a!=0&&a<10)
{
cout<<"00"<<a;
}
//total%1000=010
else if(a>9&&a<100)
{
cout<<"0"<<a;
}
//total%1000=001
else
{
cout<<a;
}
}
}
程序超时求zhu。好像是不能用cin和cout
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
10条回答 默认 最新
- 急速光粒 2021-08-29 16:35关注
可以出结果,加上
#include
最后加上
system("pause");#include<iostream> using namespace std; int main() { long long x, n; long long total = 1; cin >> x >> n; for (int i = 1; i <= n; i++) { total *= x; } int a = total % 1000; //total%1000=000 if (total<1000) { cout << total; } else { if (a == 0) { cout << "000"; } //total%1000=001 else if (a != 0 && a<10) { cout << "00" << a; } //total%1000=010 else if (a>9 && a<100) { cout << "0" << a; } //total%1000=001 else { cout << a; } } system("pause"); }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决评论 打赏 举报无用 1
悬赏问题
- ¥100 set_link_state
- ¥15 虚幻5 UE美术毛发渲染
- ¥15 CVRP 图论 物流运输优化
- ¥15 Tableau online 嵌入ppt失败
- ¥100 支付宝网页转账系统不识别账号
- ¥15 基于单片机的靶位控制系统
- ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
- ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
- ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
- ¥15 手机接入宽带网线,如何释放宽带全部速度