#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
悬赏问题
- ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
- ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
- ¥15 cmd cl 0x000007b
- ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
- ¥500 火焰左右视图、视差(基于双目相机)
- ¥100 set_link_state
- ¥15 虚幻5 UE美术毛发渲染
- ¥15 CVRP 图论 物流运输优化
- ¥15 Tableau online 嵌入ppt失败
- ¥100 支付宝网页转账系统不识别账号